You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "imgoby (via GitHub)" <gi...@apache.org> on 2024/01/04 02:55:50 UTC

[I] native-image run failed:Unable to load services for service class org.apache.logging.log4j.spi.Provider [dubbo]

imgoby opened a new issue, #13610:
URL: https://github.com/apache/dubbo/issues/13610

   version: <dubbo.version>3.3.0-beta.1</dubbo.version>
   
   ```
   ERROR StatusLogger Unable to load services for service class org.apache.logging.log4j.spi.Provider
    java.lang.InternalError: com.oracle.svm.core.jdk.UnsupportedFeatureError: Defining hidden classes at runtime is not supported.
   	at java.base@17.0.5/java.lang.invoke.InnerClassLambdaMetafactory.generateInnerClass(InnerClassLambdaMetafactory.java:413)
   	at java.base@17.0.5/java.lang.invoke.InnerClassLambdaMetafactory.spinInnerClass(InnerClassLambdaMetafactory.java:315)
   	at java.base@17.0.5/java.lang.invoke.InnerClassLambdaMetafactory.buildCallSite(InnerClassLambdaMetafactory.java:228)
   	at java.base@17.0.5/java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:341)
   	at org.apache.logging.log4j.util.ServiceLoaderUtil.loadClassloaderServices(ServiceLoaderUtil.java:93)
   	at org.apache.logging.log4j.util.ServiceLoaderUtil.loadServices(ServiceLoaderUtil.java:74)
   	at org.apache.logging.log4j.util.ServiceLoaderUtil.loadServices(ServiceLoaderUtil.java:68)
   	at org.apache.logging.log4j.util.ProviderUtil.<init>(ProviderUtil.java:67)
   	at org.apache.logging.log4j.util.ProviderUtil.lazyInit(ProviderUtil.java:145)
   	at org.apache.logging.log4j.util.ProviderUtil.hasProviders(ProviderUtil.java:129)
   	at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:90)
   	at org.apache.dubbo.common.logger.log4j2.Log4j2LoggerAdapter.<init>(Log4j2LoggerAdapter.java:35)
   	at java.base@17.0.5/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
   	at java.base@17.0.5/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
   	at org.apache.dubbo.common.logger.LoggerFactory.<clinit>(LoggerFactory.java:78)
   	at org.apache.dubbo.spring.boot.context.event.WelcomeLogoApplicationListener.onApplicationEvent(WelcomeLogoApplicationListener.java:59)
   	at org.apache.dubbo.spring.boot.context.event.WelcomeLogoApplicationListener.onApplicationEvent(WelcomeLogoApplicationListener.java:42)
   	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
   	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
   	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
   	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
   	at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136)
   	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:81)
   	at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:64)
   	at java.base@17.0.5/java.lang.Iterable.forEach(Iterable.java:75)
   	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)
   	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112)
   	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:63)
   	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:354)
   	at org.springframework.boot.SpringApplication.run(SpringApplication.java:305)
   	at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:150)
   	at com.hcll.sail.MessageProviderApplication.main(MessageProviderApplication.java:95)
   Caused by: com.oracle.svm.core.jdk.UnsupportedFeatureError: Defining hidden classes at runtime is not supported.
   	at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:89)
   	at java.base@17.0.5/java.lang.ClassLoader.defineClass0(ClassLoader.java:338)
   	at java.base@17.0.5/java.lang.System$2.defineClass(System.java:2307)
   	at java.base@17.0.5/java.lang.invoke.MethodHandles$Lookup$ClassDefiner.defineClass(MethodHandles.java:2439)
   	at java.base@17.0.5/java.lang.invoke.MethodHandles$Lookup$ClassDefiner.defineClassAsLookup(MethodHandles.java:2420)
   	at java.base@17.0.5/java.lang.invoke.MethodHandles$Lookup.defineHiddenClass(MethodHandles.java:2127)
   	at java.base@17.0.5/java.lang.invoke.InnerClassLambdaMetafactory.generateInnerClass(InnerClassLambdaMetafactory.java:407)
   	... 31 more
   ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console.
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] native-image run failed:Unable to load services for service class org.apache.logging.log4j.spi.Provider [dubbo]

Posted by "imgoby (via GitHub)" <gi...@apache.org>.
imgoby commented on issue #13610:
URL: https://github.com/apache/dubbo/issues/13610#issuecomment-1878055594

   My project use some dependency which using log4j2,so, It looks difficult to adapter to slf4j and logback 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] native-image run failed:Unable to load services for service class org.apache.logging.log4j.spi.Provider [dubbo]

Posted by "AlbumenJ (via GitHub)" <gi...@apache.org>.
AlbumenJ closed issue #13610: native-image run failed:Unable to load services for service class org.apache.logging.log4j.spi.Provider
URL: https://github.com/apache/dubbo/issues/13610


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] native-image run failed:Unable to load services for service class org.apache.logging.log4j.spi.Provider [dubbo]

Posted by "FoghostCn (via GitHub)" <gi...@apache.org>.
FoghostCn commented on issue #13610:
URL: https://github.com/apache/dubbo/issues/13610#issuecomment-1884255383

   > what about log4j-api? keep or exclude?
   > 
   > ```
   > <groupId>org.apache.logging.log4j</groupId>
   >       <artifactId>log4j-api</artifactId>
   > ```
   > 
   > something is wrong if I exclude log4j-api
   
   log4j-api just interface , keep it 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] native-image run failed:Unable to load services for service class org.apache.logging.log4j.spi.Provider [dubbo]

Posted by "imgoby (via GitHub)" <gi...@apache.org>.
imgoby commented on issue #13610:
URL: https://github.com/apache/dubbo/issues/13610#issuecomment-1888689684

   I think I should modify the code. delete org.apache.logging.log4j.LogManager


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] native-image run failed:Unable to load services for service class org.apache.logging.log4j.spi.Provider [dubbo]

Posted by "FoghostCn (via GitHub)" <gi...@apache.org>.
FoghostCn commented on issue #13610:
URL: https://github.com/apache/dubbo/issues/13610#issuecomment-1890277387

   try to check why Slf4jLoggerAdapter not load success


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] native-image run failed:Unable to load services for service class org.apache.logging.log4j.spi.Provider [dubbo]

Posted by "imgoby (via GitHub)" <gi...@apache.org>.
imgoby commented on issue #13610:
URL: https://github.com/apache/dubbo/issues/13610#issuecomment-1878096858

   what about log4j-api? keep or exclude?
   
   <groupId>org.apache.logging.log4j</groupId>
         <artifactId>log4j-api</artifactId>
   
   something is wrong if I exclude log4j-api


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] native-image run failed:Unable to load services for service class org.apache.logging.log4j.spi.Provider [dubbo]

Posted by "CrazyHZM (via GitHub)" <gi...@apache.org>.
CrazyHZM commented on issue #13610:
URL: https://github.com/apache/dubbo/issues/13610#issuecomment-1876247864

   @imgoby 
   Please provide `native-maven-plugin` version information.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] native-image run failed:Unable to load services for service class org.apache.logging.log4j.spi.Provider [dubbo]

Posted by "imgoby (via GitHub)" <gi...@apache.org>.
imgoby commented on issue #13610:
URL: https://github.com/apache/dubbo/issues/13610#issuecomment-1888762956

   org.apache.logging.log4j.LogManager has been deleted from my copying source from elasticsearch-rest-high-level-client.
   But something wrong is here: If there is not log4j2 in your application,It will be failed too.
   
   
   
   ```
   <exclusions>
                   <exclusion>
                       <groupId>org.apache.logging.log4j</groupId>
                       <artifactId>log4j-api</artifactId>
                   </exclusion>
               </exclusions>
   ```
   
   
   ![image](https://github.com/apache/dubbo/assets/27885492/4b6ea306-cd34-47c7-ad6c-640f3c315a6d)
   
   ![image](https://github.com/apache/dubbo/assets/27885492/af7bc2ab-d66e-4a8c-8b02-9bb6b33bde3d)
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] native-image run failed:Unable to load services for service class org.apache.logging.log4j.spi.Provider [dubbo]

Posted by "imgoby (via GitHub)" <gi...@apache.org>.
imgoby commented on issue #13610:
URL: https://github.com/apache/dubbo/issues/13610#issuecomment-1888794586

   
   ![image](https://github.com/apache/dubbo/assets/27885492/df8e9175-2d7d-4ebc-99e1-1fbfd3780482)
   The problem seems to be here, why does Log4j2LoggerAdapter loaded ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] native-image run failed:Unable to load services for service class org.apache.logging.log4j.spi.Provider [dubbo]

Posted by "FoghostCn (via GitHub)" <gi...@apache.org>.
FoghostCn commented on issue #13610:
URL: https://github.com/apache/dubbo/issues/13610#issuecomment-1876856901

   the lastest metadataRepository support log4j already,but lastest native-build-tool maven plugin buildin metadataRepository is outdate,you can config it Manually
   
   ```xml
   <plugin>
       <groupId>org.graalvm.buildtools</groupId>
       <artifactId>native-maven-plugin</artifactId>
       <version>0.9.28</version>
       <configuration>
           <classesDirectory>${project.build.outputDirectory}</classesDirectory>
           <metadataRepository>
               <enabled>true</enabled>
   <!--    set version to 0.3.5 support log4j        -->
               <version>0.3.5</version>
           </metadataRepository>
           <requiredVersion>22.3</requiredVersion>
           <mainClass>org.apache.dubbo.logging.provider.Application</mainClass>
       </configuration>
       <executions>
           <execution>
               <id>add-reachability-metadata</id>
               <goals>
                   <goal>add-reachability-metadata</goal>
               </goals>
           </execution>
       </executions>
   </plugin>
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] native-image run failed:Unable to load services for service class org.apache.logging.log4j.spi.Provider [dubbo]

Posted by "FoghostCn (via GitHub)" <gi...@apache.org>.
FoghostCn commented on issue #13610:
URL: https://github.com/apache/dubbo/issues/13610#issuecomment-1878085489

   > My project uses some dependencies which using log4j2. so, It looks difficult to adapte to slf4j and logback .
   
   use log4j-to-slf4j and exclude log4j2 should work
   
   ```xml
   <dependency>
       <groupId>org.apache.logging.log4j</groupId>
       <artifactId>log4j-to-slf4j</artifactId>
       <version>${log4j2.version}</version>
   </dependency>
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] native-image run failed:Unable to load services for service class org.apache.logging.log4j.spi.Provider [dubbo]

Posted by "imgoby (via GitHub)" <gi...@apache.org>.
imgoby commented on issue #13610:
URL: https://github.com/apache/dubbo/issues/13610#issuecomment-1888504111

   ![image](https://github.com/apache/dubbo/assets/27885492/2db8f6f8-f143-4caf-ac71-cf76fb4f3ae4)
   
   spring-boot-starter-logging has include log4j-api and log4j-to-slf4j yet.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] native-image run failed:Unable to load services for service class org.apache.logging.log4j.spi.Provider [dubbo]

Posted by "imgoby (via GitHub)" <gi...@apache.org>.
imgoby commented on issue #13610:
URL: https://github.com/apache/dubbo/issues/13610#issuecomment-1876571019

   <native-maven-plugin.version>0.9.28</native-maven-plugin.version>
   
   It may be the log4j 's issue.
   
   https://github.com/spring-projects/spring-boot/issues/33470


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] native-image run failed:Unable to load services for service class org.apache.logging.log4j.spi.Provider [dubbo]

Posted by "kimmking (via GitHub)" <gi...@apache.org>.
kimmking commented on issue #13610:
URL: https://github.com/apache/dubbo/issues/13610#issuecomment-1889736508

   Yes, if there is a Slf4jLoggerAdapter , in the first case branch of switch statement, it breaks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] native-image run failed:Unable to load services for service class org.apache.logging.log4j.spi.Provider [dubbo]

Posted by "imgoby (via GitHub)" <gi...@apache.org>.
imgoby commented on issue #13610:
URL: https://github.com/apache/dubbo/issues/13610#issuecomment-1888688325

   this is a simple demo using log4j2 and spring-boot-stater.
   The issue can be reproduced.
   
   ```
   @RestController
   
   public class Log4j2Controller {
       private static final Logger logger = LogManager.getLogger(Log4j2Controller.class);
   
       @GetMapping({"/log4j2/demo"})
       public String send() {
           logger.info("hello");
           return "log4j2";
       }
   }
   
   ```
   
   https://github.com/imgoby/spring-cloud-alibaba-dubbo-native/tree/main/spring-cloud-alibaba-log4j2-native-image
   
   The production environment uses this dependency:
   ```
   <dependency>
                   <groupId>org.elasticsearch.client</groupId>
                   <artifactId>elasticsearch-rest-high-level-client</artifactId>
                   <version>7.17.4</version>
               </dependency>
   ```
   It uses org.apache.logging.log4j.LogManager.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org