apache / dubbo

The java implementation of Apache Dubbo. An RPC and microservice framework.
https://dubbo.apache.org/
Apache License 2.0
40.51k stars 26.43k forks source link

Native-image base springNative and Dubbo build failure #7682

Closed jack161641 closed 10 months ago

jack161641 commented 3 years ago

Environment

Steps to reproduce this issue

  1. graalvm native-image build dubbo application
  2. I get error messages when I start build,It may be caused by Dubbo autoconfig

Pls. provide [GitHub address] to reproduce this issue. The sample code is https://github.com/jack161641/gs-rest-service.git

Expected Result

build success What do you expected from the above steps?

Actual Result

build failure What actually happens? build failure If there is an exception, please attach the exception trace:

java.lang.NullPointerException: null at org.apache.dubbo.config.bootstrap.DubboBootstrap.hasExportedServices(DubboBootstrap.java:937) ~[dubbo-2.7.9.jar:2.7.9] at org.apache.dubbo.config.bootstrap.DubboBootstrap.start(DubboBootstrap.java:899) ~[dubbo-2.7.9.jar:2.7.9] at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextRefreshedEvent(DubboBootstrapApplicationListener.java:62) ~[dubbo-2.7.9.jar:2.7.9] at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:55) ~[dubbo-2.7.9.jar:2.7.9] at com.alibaba.spring.context.OnceApplicationContextEventListener.onApplicationEvent(OnceApplicationContextEventListener.java:52) ~[spring-context-support-1.0.10.jar:na] at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-5.3.6.jar:5.3.6] at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-5.3.6.jar:5.3.6] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-5.3.6.jar:5.3.6] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) ~[spring-context-5.3.6.jar:5.3.6] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378) ~[spring-context-5.3.6.jar:5.3.6] at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:938) ~[spring-context-5.3.6.jar:5.3.6] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) ~[spring-context-5.3.6.jar:5.3.6] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:782) ~[spring-boot-2.4.5.jar:2.4.5] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:774) ~[spring-boot-2.4.5.jar:2.4.5] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439) ~[spring-boot-2.4.5.jar:2.4.5] Just put your stack trace here!

xiaoheng1 commented 3 years ago

pls config metadata-config address using ip+port and try.

jack161641 commented 3 years ago

pls config metadata-config address using ip+port and try.

The dubbo api config is ,It may be caused by Graalvm not support reflection configCenterConfig.setAddress("172.16.3.100"); configCenterConfig.setPort(2181);

xiaoheng1 commented 3 years ago

at org.apache.dubbo.config.bootstrap.DubboBootstrap.hasExportedServices maybe metadata-report error.

in my opinion, you should ensure dubbo applicant run successfully, and then use Graalvm build dubbo applicantion.

jack161641 commented 3 years ago

at org.apache.dubbo.config.bootstrap.DubboBootstrap.hasExportedServices maybe metadata-report error.

in my opinion, you should ensure dubbo applicant run successfully, and then use Graalvm build dubbo applicantion.

Yes, I solved this problem because I lacked dependencies. Now the build is successful, but an error is reported when running

[admin@izuf6iqbgyn5z3cczptzb3z complete]$ ./target/com.example.restservice.restserviceapplication 2021-05-14 14:06:57.917 ERROR 2160 --- [ main] o.s.boot.SpringApplication : Application run failed java.lang.ExceptionInInitializerError: null at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:315) ~[na:na] at org.apache.dubbo.spring.boot.context.event.WelcomeLogoApplicationListener.buildBannerText(WelcomeLogoApplicationListener.java:79) ~[na:na] at org.apache.dubbo.spring.boot.context.event.WelcomeLogoApplicationListener.onApplicationEvent(WelcomeLogoApplicationListener.java:60) ~[na:na] at org.apache.dubbo.spring.boot.context.event.WelcomeLogoApplicationListener.onApplicationEvent(WelcomeLogoApplicationListener.java:41) ~[na:na] at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[na:na] at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[na:na] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[na:na] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131) ~[na:na] at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82) ~[com.example.restservice.restserviceapplication:2.4.5] at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63) ~[na:na] at java.util.ArrayList.forEach(ArrayList.java:1259) ~[com.example.restservice.restserviceapplication:na] at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117) ~[na:na] at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111) ~[na:na] at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62) ~[na:na] at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:375) [com.example.restservice.restserviceapplication:2.4.5] at org.springframework.boot.SpringApplication.run(SpringApplication.java:333) [com.example.restservice.restserviceapplication:2.4.5] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1340) [com.example.restservice.restserviceapplication:2.4.5] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329) [com.example.restservice.restserviceapplication:2.4.5] at com.example.restservice.RestServiceApplication.main(RestServiceApplication.java:14) [com.example.restservice.restserviceapplication:0.0.1-SNAPSHOT] Caused by: java.lang.NullPointerException: null at org.apache.dubbo.common.logger.LoggerFactory.lambda$getLogger$0(LoggerFactory.java:111) ~[na:na] at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) ~[na:na] at org.apache.dubbo.common.logger.LoggerFactory.getLogger(LoggerFactory.java:111) ~[na:na] at org.apache.dubbo.common.Version.<clinit>(Version.java:39) ~[na:na] at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375) ~[na:na] at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295) ~[na:na] ... 18 common frames omitted The reproduce is https://github.com/jack161641/gs-rest-service.git

xiaoheng1 commented 3 years ago

at org.apache.dubbo.config.bootstrap.DubboBootstrap.hasExportedServices maybe metadata-report error. in my opinion, you should ensure dubbo applicant run successfully, and then use Graalvm build dubbo applicantion.

Yes, I solved this problem because I lacked dependencies. Now the build is successful, but an error is reported when running

[admin@izuf6iqbgyn5z3cczptzb3z complete]$ ./target/com.example.restservice.restserviceapplication 2021-05-14 14:06:57.917 ERROR 2160 --- [ main] o.s.boot.SpringApplication : Application run failed java.lang.ExceptionInInitializerError: null at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:315) ~[na:na] at org.apache.dubbo.spring.boot.context.event.WelcomeLogoApplicationListener.buildBannerText(WelcomeLogoApplicationListener.java:79) ~[na:na] at org.apache.dubbo.spring.boot.context.event.WelcomeLogoApplicationListener.onApplicationEvent(WelcomeLogoApplicationListener.java:60) ~[na:na] at org.apache.dubbo.spring.boot.context.event.WelcomeLogoApplicationListener.onApplicationEvent(WelcomeLogoApplicationListener.java:41) ~[na:na] at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[na:na] at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[na:na] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[na:na] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131) ~[na:na] at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82) ~[com.example.restservice.restserviceapplication:2.4.5] at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63) ~[na:na] at java.util.ArrayList.forEach(ArrayList.java:1259) ~[com.example.restservice.restserviceapplication:na] at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117) ~[na:na] at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111) ~[na:na] at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62) ~[na:na] at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:375) [com.example.restservice.restserviceapplication:2.4.5] at org.springframework.boot.SpringApplication.run(SpringApplication.java:333) [com.example.restservice.restserviceapplication:2.4.5] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1340) [com.example.restservice.restserviceapplication:2.4.5] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329) [com.example.restservice.restserviceapplication:2.4.5] at com.example.restservice.RestServiceApplication.main(RestServiceApplication.java:14) [com.example.restservice.restserviceapplication:0.0.1-SNAPSHOT] Caused by: java.lang.NullPointerException: null at org.apache.dubbo.common.logger.LoggerFactory.lambda$getLogger$0(LoggerFactory.java:111) ~[na:na] at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) ~[na:na] at org.apache.dubbo.common.logger.LoggerFactory.getLogger(LoggerFactory.java:111) ~[na:na] at org.apache.dubbo.common.Version.<clinit>(Version.java:39) ~[na:na] at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375) ~[na:na] at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295) ~[na:na] ... 18 common frames omitted The reproduce is https://github.com/jack161641/gs-rest-service.git

Sorry, dubbo's integration with Native-image is still under discussion, you can subscribe to the dev@dubbo.apache.org mailing group and follow it. You are welcome to give suggestions on the combination of dubbo and Native-image.

CrazyHZM commented 10 months ago

Native has been refactored. Please try the latest version 3.3.x.