alibaba / spring-cloud-alibaba

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.
https://sca.aliyun.com
Apache License 2.0
27.42k stars 8.17k forks source link

Spring Native run failed! #3022

Closed KillerJmc closed 2 months ago

KillerJmc commented 1 year ago

Which Component Nacos Discovery

Describe the bug I ran mvn native:compile on Ubuntu and successfully got an executable native file. When I started this app, I got some error logs and then the app shutdown. And then I also did this work on Windows and it failed because of the same reason!

To Reproduce Native App Running logs:

2023-01-01T16:02:21.917+08:00  INFO 27086 --- [           main] c.a.n.client.env.SearchableProperties    : properties search order:PROPERTIES->JVM->ENV->DEFAULT_SETTING
2023-01-01T16:02:21.917+08:00  WARN 27086 --- [           main] c.a.nacos.client.logging.NacosLogging    : Load Logback Configuration of Nacos fail, message: org.slf4j.impl.StaticLoggerBinder

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.0.0)

2023-01-01T16:02:21.920+08:00  INFO 27086 --- [           main] com.example.demo.Demo4Application        : Starting AOT-processed Demo4Application using Java 17.0.5 with PID 27086 (/home/jmc/demo4/build/native/nativeCompile/demo4 started by root in /home/jmc/demo4/build/native/nativeCompile)
2023-01-01T16:02:21.920+08:00  INFO 27086 --- [           main] com.example.demo.Demo4Application        : No active profile set, falling back to 1 default profile: "default"
2023-01-01T16:02:21.921+08:00  INFO 27086 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=f880f0b5-e998-3381-a879-8fb548c73dff
2023-01-01T16:02:21.931+08:00  INFO 27086 --- [           main] o.s.b.w.embedded.tomcat.TaomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2023-01-01T16:02:21.932+08:00  INFO 27086 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2023-01-01T16:02:21.932+08:00  INFO 27086 --- [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.1]
2023-01-01T16:02:21.936+08:00  INFO 27086 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2023-01-01T16:02:21.936+08:00  INFO 27086 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 16 ms
2023-01-01T16:02:22.962+08:00  INFO 27086 --- [           main] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
2023-01-01T16:02:23.966+08:00  INFO 27086 --- [           main] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
2023-01-01T16:02:23.985+08:00  INFO 27086 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2023-01-01T16:02:23.985+08:00  INFO 27086 --- [           main] c.a.n.client.env.SearchableProperties    : properties search order:PROPERTIES->JVM->ENV->DEFAULT_SETTING
2023-01-01T16:02:23.986+08:00  WARN 27086 --- [           main] c.a.nacos.client.logging.NacosLogging    : Load Logback Configuration of Nacos fail, message: org.slf4j.impl.StaticLoggerBinder
2023-01-01T16:02:23.986+08:00  INFO 27086 --- [           main] com.alibaba.nacos.client.naming          : initializer namespace from System Property : null
2023-01-01T16:02:23.986+08:00  INFO 27086 --- [           main] com.alibaba.nacos.client.naming          : initializer namespace from System Environment :null
2023-01-01T16:02:23.986+08:00  INFO 27086 --- [           main] com.alibaba.nacos.client.naming          : initializer namespace from System Property :
2023-01-01T16:02:23.988+08:00 ERROR 27086 --- [           main] c.a.nacos.common.notify.NotifyCenter     : Service class newInstance has error :

java.lang.InstantiationException: com.alibaba.nacos.common.notify.DefaultPublisher
        at java.base@17.0.5/java.lang.Class.newInstance(DynamicHub.java:639) ~[demo4:na]
        at com.alibaba.nacos.common.notify.NotifyCenter.lambda$static$0(NotifyCenter.java:89) ~[na:na]
        at com.alibaba.nacos.common.notify.EventPublisherFactory.apply(EventPublisherFactory.java:26) ~[demo4:na]
        at com.alibaba.nacos.common.utils.MapUtil.computeIfAbsent(MapUtil.java:153) ~[na:na]
        at com.alibaba.nacos.common.notify.NotifyCenter.registerToPublisher(NotifyCenter.java:347) ~[na:na]
        at com.alibaba.nacos.common.notify.NotifyCenter.registerToPublisher(NotifyCenter.java:328) ~[na:na]
        at com.alibaba.nacos.client.naming.NacosNamingService.init(NacosNamingService.java:99) ~[na:na]
        at com.alibaba.nacos.client.naming.NacosNamingService.<init>(NacosNamingService.java:85) ~[na:na]
        at java.base@17.0.5/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[demo4:na]
        at java.base@17.0.5/java.lang.reflect.Constructor.newInstance(Constructor.java:480) ~[demo4:na]
        at com.alibaba.nacos.api.naming.NamingFactory.createNamingService(NamingFactory.java:59) ~[na:na]
        at com.alibaba.nacos.api.NacosFactory.createNamingService(NacosFactory.java:77) ~[na:na]
        at com.alibaba.cloud.nacos.NacosServiceManager.createNewNamingService(NacosServiceManager.java:99) ~[demo4:2022.0.0.0-RC1]
        at com.alibaba.cloud.nacos.NacosServiceManager.buildNamingService(NacosServiceManager.java:90) ~[demo4:2022.0.0.0-RC1]
        at com.alibaba.cloud.nacos.NacosServiceManager.getNamingService(NacosServiceManager.java:46) ~[demo4:2022.0.0.0-RC1]
        at com.alibaba.cloud.nacos.registry.NacosServiceRegistry.namingService(NacosServiceRegistry.java:193) ~[demo4:2022.0.0.0-RC1]
        at com.alibaba.cloud.nacos.registry.NacosServiceRegistry.register(NacosServiceRegistry.java:68) ~[demo4:2022.0.0.0-RC1]
        at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.register(AbstractAutoServiceRegistration.java:264) ~[demo4:4.0.0]
        at com.alibaba.cloud.nacos.registry.NacosAutoServiceRegistration.register(NacosAutoServiceRegistration.java:78) ~[demo4:2022.0.0.0-RC1]
        at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.start(AbstractAutoServiceRegistration.java:156) ~[demo4:4.0.0]
        at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.onApplicationEvent(AbstractAutoServiceRegistration.java:119) ~[demo4:4.0.0]
        at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.onApplicationEvent(AbstractAutoServiceRegistration.java:49) ~[demo4:4.0.0]
        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.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:413) ~[demo4:6.0.2]
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:370) ~[demo4:6.0.2]
        at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:47) ~[na:na]
        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) ~[demo4:6.0.2]
        at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) ~[na:na]
        at java.base@17.0.5/java.lang.Iterable.forEach(Iterable.java:75) ~[demo4:na]
        at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155) ~[demo4:6.0.2]
        at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) ~[demo4:6.0.2]
        at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:932) ~[demo4:6.0.2]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:587) ~[demo4:6.0.2]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[demo4:3.0.0]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[demo4:3.0.0]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432) ~[demo4:3.0.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[demo4:3.0.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[demo4:3.0.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[demo4:3.0.0]
        at com.example.demo.Demo4Application.main(Demo4Application.java:10) ~[demo4:na]
Caused by: java.lang.NoSuchMethodException: com.alibaba.nacos.common.notify.DefaultPublisher.<init>()
        at java.base@17.0.5/java.lang.Class.getConstructor0(DynamicHub.java:3585) ~[demo4:na]
        at java.base@17.0.5/java.lang.Class.newInstance(DynamicHub.java:626) ~[demo4:na]
        ... 41 common frames omitted

2023-01-01T16:02:23.988+08:00  WARN 27086 --- [           main] w.s.c.ServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'
2023-01-01T16:02:23.990+08:00  INFO 27086 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2023-01-01T16:02:23.992+08:00 ERROR 27086 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'
        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181) ~[demo4:6.0.2]
        at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) ~[na:na]
        at java.base@17.0.5/java.lang.Iterable.forEach(Iterable.java:75) ~[demo4:na]
        at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155) ~[demo4:6.0.2]
        at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) ~[demo4:6.0.2]
        at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:932) ~[demo4:6.0.2]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:587) ~[demo4:6.0.2]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[demo4:3.0.0]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[demo4:3.0.0]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432) ~[demo4:3.0.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[demo4:3.0.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[demo4:3.0.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[demo4:3.0.0]
        at com.example.demo.Demo4Application.main(Demo4Application.java:10) ~[demo4:na]
Caused by: java.lang.RuntimeException: ErrCode:-400, ErrMsg:com.alibaba.nacos.common.notify.DefaultPublisher.<init>()
        at com.alibaba.cloud.nacos.NacosServiceManager.createNewNamingService(NacosServiceManager.java:102) ~[demo4:2022.0.0.0-RC1]
        at com.alibaba.cloud.nacos.NacosServiceManager.buildNamingService(NacosServiceManager.java:90) ~[demo4:2022.0.0.0-RC1]
        at com.alibaba.cloud.nacos.NacosServiceManager.getNamingService(NacosServiceManager.java:46) ~[demo4:2022.0.0.0-RC1]
        at com.alibaba.cloud.nacos.registry.NacosServiceRegistry.namingService(NacosServiceRegistry.java:193) ~[demo4:2022.0.0.0-RC1]
        at com.alibaba.cloud.nacos.registry.NacosServiceRegistry.register(NacosServiceRegistry.java:68) ~[demo4:2022.0.0.0-RC1]
        at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.register(AbstractAutoServiceRegistration.java:264) ~[demo4:4.0.0]
        at com.alibaba.cloud.nacos.registry.NacosAutoServiceRegistration.register(NacosAutoServiceRegistration.java:78) ~[demo4:2022.0.0.0-RC1]
        at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.start(AbstractAutoServiceRegistration.java:156) ~[demo4:4.0.0]
        at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.onApplicationEvent(AbstractAutoServiceRegistration.java:119) ~[demo4:4.0.0]
        at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.onApplicationEvent(AbstractAutoServiceRegistration.java:49) ~[demo4:4.0.0]
        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.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:413) ~[demo4:6.0.2]
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:370) ~[demo4:6.0.2]
        at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:47) ~[na:na]
        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) ~[demo4:6.0.2]
        ... 13 common frames omitted
Caused by: com.alibaba.nacos.api.exception.NacosException: java.lang.reflect.InvocationTargetException
        at com.alibaba.nacos.api.naming.NamingFactory.createNamingService(NamingFactory.java:61) ~[na:na]
        at com.alibaba.nacos.api.NacosFactory.createNamingService(NacosFactory.java:77) ~[na:na]
        at com.alibaba.cloud.nacos.NacosServiceManager.createNewNamingService(NacosServiceManager.java:99) ~[demo4:2022.0.0.0-RC1]
        ... 29 common frames omitted
Caused by: java.lang.reflect.InvocationTargetException: null
        at java.base@17.0.5/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[demo4:na]
        at java.base@17.0.5/java.lang.reflect.Constructor.newInstance(Constructor.java:480) ~[demo4:na]
        at com.alibaba.nacos.api.naming.NamingFactory.createNamingService(NamingFactory.java:59) ~[na:na]
        ... 31 common frames omitted
Caused by: com.alibaba.nacos.api.exception.runtime.NacosRuntimeException: java.lang.InstantiationException: com.alibaba.nacos.common.notify.DefaultPublisher
        at com.alibaba.nacos.common.notify.NotifyCenter.lambda$static$0(NotifyCenter.java:94) ~[na:na]
        at com.alibaba.nacos.common.notify.EventPublisherFactory.apply(EventPublisherFactory.java:26) ~[demo4:na]
        at com.alibaba.nacos.common.utils.MapUtil.computeIfAbsent(MapUtil.java:153) ~[na:na]
        at com.alibaba.nacos.common.notify.NotifyCenter.registerToPublisher(NotifyCenter.java:347) ~[na:na]
        at com.alibaba.nacos.common.notify.NotifyCenter.registerToPublisher(NotifyCenter.java:328) ~[na:na]
        at com.alibaba.nacos.client.naming.NacosNamingService.init(NacosNamingService.java:99) ~[na:na]
        at com.alibaba.nacos.client.naming.NacosNamingService.<init>(NacosNamingService.java:85) ~[na:na]
        ... 34 common frames omitted
Caused by: java.lang.InstantiationException: com.alibaba.nacos.common.notify.DefaultPublisher
        at java.base@17.0.5/java.lang.Class.newInstance(DynamicHub.java:639) ~[demo4:na]
        at com.alibaba.nacos.common.notify.NotifyCenter.lambda$static$0(NotifyCenter.java:89) ~[na:na]
        ... 40 common frames omitted
Caused by: java.lang.NoSuchMethodException: com.alibaba.nacos.common.notify.DefaultPublisher.<init>()
        at java.base@17.0.5/java.lang.Class.getConstructor0(DynamicHub.java:3585) ~[demo4:na]
        at java.base@17.0.5/java.lang.Class.newInstance(DynamicHub.java:626) ~[demo4:na]
        ... 41 common frames omitted

2023-01-01T16:02:24.002+08:00  WARN 27086 --- [       Thread-4] c.a.nacos.common.notify.NotifyCenter     : [NotifyCenter] Start destroying Publisher
2023-01-01T16:02:24.002+08:00  WARN 27086 --- [       Thread-4] c.a.nacos.common.notify.NotifyCenter     : [NotifyCenter] Destruction of the end

Maven pom file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>demo4</artifactId>
    <version>1.0.0</version>

    <properties>
        <java.version>17</java.version>
    </properties>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.0.0</version>
        <relativePath/>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>2022.0.0.0-RC1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

mvn native:compile running logs:

root@Jmc-PC:/home/jmc/demo4# ./mvnw native:compile
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< com.example:demo4 >--------------------------
[INFO] Building demo4 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> native-maven-plugin:0.9.18:compile (default-cli) > package @ demo4 >>>
[INFO]
[INFO] --- maven-resources-plugin:3.3.0:resources (default-resources) @ demo4 ---
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ demo4 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.3.0:testResources (default-testResources) @ demo4 ---
[INFO] skip non existing resourceDirectory /home/jmc/demo4/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ demo4 ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ demo4 ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:3.3.0:jar (default-jar) @ demo4 ---
[INFO]
[INFO] --- spring-boot-maven-plugin:3.0.0:repackage (repackage) @ demo4 ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] <<< native-maven-plugin:0.9.18:compile (default-cli) < package @ demo4 <<<
[INFO]
[INFO]
[INFO] --- native-maven-plugin:0.9.18:compile (default-cli) @ demo4 ---
[INFO] Found GraalVM installation from JAVA_HOME variable.
[WARNING] Properties file at 'jar:file:///root/.m2/repository/com/alibaba/nacos/nacos-client/2.2.1-RC/nacos-client-2.2.1-RC.jar!/META-INF/native-image/io.netty/common/native-image.properties' does not match the recommended 'META-INF/native-image/com.alibaba.nacos/nacos-client/native-image.properties' layout.
[WARNING] Properties file at 'jar:file:///root/.m2/repository/com/alibaba/nacos/nacos-client/2.2.1-RC/nacos-client-2.2.1-RC.jar!/META-INF/native-image/io.netty/buffer/native-image.properties' does not match the recommended 'META-INF/native-image/com.alibaba.nacos/nacos-client/native-image.properties' layout.
[WARNING] Properties file at 'jar:file:///root/.m2/repository/com/alibaba/nacos/nacos-client/2.2.1-RC/nacos-client-2.2.1-RC.jar!/META-INF/native-image/io.netty/transport/native-image.properties' does not match the recommended 'META-INF/native-image/com.alibaba.nacos/nacos-client/native-image.properties' layout.
[WARNING] Properties file at 'jar:file:///root/.m2/repository/com/alibaba/nacos/nacos-client/2.2.1-RC/nacos-client-2.2.1-RC.jar!/META-INF/native-image/io.netty/handler/native-image.properties' does not match the recommended 'META-INF/native-image/com.alibaba.nacos/nacos-client/native-image.properties' layout.
[WARNING] Properties file at 'jar:file:///root/.m2/repository/com/alibaba/nacos/nacos-client/2.2.1-RC/nacos-client-2.2.1-RC.jar!/META-INF/native-image/io.netty/codec-http/native-image.properties' does not match the recommended 'META-INF/native-image/com.alibaba.nacos/nacos-client/native-image.properties' layout.
[WARNING] Properties file at 'jar:file:///root/.m2/repository/com/alibaba/nacos/nacos-client/2.2.1-RC/nacos-client-2.2.1-RC.jar!/META-INF/native-image/io.netty/codec-http2/native-image.properties' does not match the recommended 'META-INF/native-image/com.alibaba.nacos/nacos-client/native-image.properties' layout.
[INFO] Executing: /root/graalvm-ce-java17-22.3.0/bin/native-image -cp /home/jmc/demo4/target/classes:/root/.m2/repository/org/slf4j/jul-to-slf4j/2.0.4/jul-to-slf4j-2.0.4.jar:/root/.m2/repository/org/springframework/boot/spring-boot-starter-json/3.0.0/spring-boot-starter-json-3.0.0.jar:/root/.m2/repository/ch/qos/logback/logback-classic/1.4.5/logback-classic-1.4.5.jar:/root/.m2/repository/org/springframework/boot/spring-boot-starter-web/3.0.0/spring-boot-starter-web-3.0.0.jar:/root/.m2/repository/com/alibaba/nacos/nacos-auth-plugin/2.2.1-RC/nacos-auth-plugin-2.2.1-RC.jar:/root/.m2/repository/org/springframework/spring-beans/6.0.2/spring-beans-6.0.2.jar:/root/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/10.1.1/tomcat-embed-el-10.1.1.jar:/root/.m2/repository/commons-codec/commons-codec/1.15/commons-codec-1.15.jar:/root/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.14.1/jackson-core-2.14.1.jar:/root/.m2/repository/org/apache/logging/log4j/log4j-api/2.19.0/log4j-api-2.19.0.jar:/root/.m2/repository/org/springframework/spring-expression/6.0.2/spring-expression-6.0.2.jar:/root/.m2/repository/org/springframework/spring-webmvc/6.0.2/spring-webmvc-6.0.2.jar:/root/.m2/repository/org/springframework/boot/spring-boot/3.0.0/spring-boot-3.0.0.jar:/root/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/10.1.1/tomcat-embed-core-10.1.1.jar:/root/.m2/repository/org/springframework/spring-aop/6.0.2/spring-aop-6.0.2.jar:/root/.m2/repository/com/alibaba/nacos/nacos-encryption-plugin/2.2.1-RC/nacos-encryption-plugin-2.2.1-RC.jar:/root/.m2/repository/com/alibaba/nacos/nacos-client/2.2.1-RC/nacos-client-2.2.1-RC.jar:/root/.m2/repository/org/apache/httpcomponents/httpcore-nio/4.4.15/httpcore-nio-4.4.15.jar:/root/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.14.1/jackson-datatype-jdk8-2.14.1.jar:/root/.m2/repository/io/prometheus/simpleclient_tracer_otel_agent/0.16.0/simpleclient_tracer_otel_agent-0.16.0.jar:/root/.m2/repository/org/springframework/cloud/spring-cloud-commons/4.0.0/spring-cloud-commons-4.0.0.jar:/root/.m2/repository/org/springframework/spring-web/6.0.2/spring-web-6.0.2.jar:/root/.m2/repository/io/prometheus/simpleclient_tracer_common/0.16.0/simpleclient_tracer_common-0.16.0.jar:/root/.m2/repository/io/prometheus/simpleclient/0.16.0/simpleclient-0.16.0.jar:/root/.m2/repository/org/apache/httpcomponents/httpclient/4.5.13/httpclient-4.5.13.jar:/root/.m2/repository/com/alibaba/cloud/spring-cloud-starter-alibaba-nacos-discovery/2022.0.0.0-RC1/spring-cloud-starter-alibaba-nacos-discovery-2022.0.0.0-RC1.jar:/root/.m2/repository/io/prometheus/simpleclient_tracer_otel/0.16.0/simpleclient_tracer_otel-0.16.0.jar:/root/.m2/repository/ch/qos/logback/logback-core/1.4.5/logback-core-1.4.5.jar:/root/.m2/repository/org/springframework/cloud/spring-cloud-context/4.0.0/spring-cloud-context-4.0.0.jar:/root/.m2/repository/jakarta/annotation/jakarta.annotation-api/2.1.1/jakarta.annotation-api-2.1.1.jar:/root/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.14.1/jackson-annotations-2.14.1.jar:/root/.m2/repository/com/alibaba/cloud/spring-cloud-alibaba-commons/2022.0.0.0-RC1/spring-cloud-alibaba-commons-2022.0.0.0-RC1.jar:/root/.m2/repository/org/springframework/spring-core/6.0.2/spring-core-6.0.2.jar:/root/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.14.1/jackson-module-parameter-names-2.14.1.jar:/root/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/10.1.1/tomcat-embed-websocket-10.1.1.jar:/root/.m2/repository/org/springframework/spring-jcl/6.0.2/spring-jcl-6.0.2.jar:/root/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/3.0.0/spring-boot-autoconfigure-3.0.0.jar:/root/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/3.0.0/spring-boot-starter-tomcat-3.0.0.jar:/root/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.14.1/jackson-datatype-jsr310-2.14.1.jar:/root/.m2/repository/com/alibaba/spring/spring-context-support/1.0.11/spring-context-support-1.0.11.jar:/root/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.19.0/log4j-to-slf4j-2.19.0.jar:/root/.m2/repository/org/springframework/boot/spring-boot-starter/3.0.0/spring-boot-starter-3.0.0.jar:/root/.m2/repository/org/springframework/security/spring-security-crypto/6.0.0/spring-security-crypto-6.0.0.jar:/root/.m2/repository/org/springframework/boot/spring-boot-starter-logging/3.0.0/spring-boot-starter-logging-3.0.0.jar:/root/.m2/repository/org/apache/httpcomponents/httpcore/4.4.15/httpcore-4.4.15.jar:/root/.m2/repository/org/slf4j/slf4j-api/2.0.4/slf4j-api-2.0.4.jar:/root/.m2/repository/org/springframework/spring-context/6.0.2/spring-context-6.0.2.jar:/root/.m2/repository/io/micrometer/micrometer-observation/1.10.2/micrometer-observation-1.10.2.jar:/root/.m2/repository/org/yaml/snakeyaml/1.33/snakeyaml-1.33.jar:/root/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.14.1/jackson-databind-2.14.1.jar:/root/.m2/repository/org/apache/httpcomponents/httpasyncclient/4.1.5/httpasyncclient-4.1.5.jar:/root/.m2/repository/io/micrometer/micrometer-commons/1.10.2/micrometer-commons-1.10.2.jar --no-fallback -H:Path=/home/jmc/demo4/target -H:Name=demo4
================================================================================================================GraalVM Native Image: Generating 'demo4' (executable)...
================================================================================================================Warning: Could not resolve io.netty.channel.socket.nio.NioServerSocketChannel for reflection configuration. Reason: java.lang.ClassNotFoundException: io.netty.channel.socket.nio.NioServerSocketChannel.
[1/7] Initializing...                                                                            (9.4s @ 0.31GB) Version info: 'GraalVM 22.3.0 Java 17 CE'
 Java version info: '17.0.5+8-jvmci-22.3-b08'
 C compiler: gcc (linux, x86_64, 11.3.0)
 Garbage collector: Serial GC
 1 user-specific feature(s)
 - org.springframework.aot.nativex.feature.PreComputeFieldFeature
The bundle named: org.apache.el.Messages, has not been found. If the bundle is part of a module, verify the bundle name is a fully qualified class name. Otherwise verify the bundle path is accessible in the classpath.
Field org.apache.commons.logging.LogAdapter#log4jSpiPresent set to true at build time
Field org.apache.commons.logging.LogAdapter#log4jSlf4jProviderPresent set to true at build time
Field org.apache.commons.logging.LogAdapter#slf4jSpiPresent set to true at build time
Field org.apache.commons.logging.LogAdapter#slf4jApiPresent set to true at build time
Field org.springframework.core.NativeDetector#imageCode set to true at build time
Field org.springframework.core.KotlinDetector#kotlinPresent set to false at build time
Field org.springframework.core.KotlinDetector#kotlinReflectPresent set to false at build time
Field org.springframework.format.support.DefaultFormattingConversionService#jsr354Present set to false at build time
Field org.springframework.cglib.core.AbstractClassGenerator#imageCode set to true at build time
Field org.springframework.boot.logging.java.JavaLoggingSystem$Factory#PRESENT set to true at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#romePresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jaxb2Present set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2Present set to true at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2XmlPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2SmilePresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2CborPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#gsonPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jsonbPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#kotlinSerializationCborPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#kotlinSerializationJsonPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#kotlinSerializationProtobufPresent set to false at build time
Field org.springframework.boot.logging.log4j2.Log4J2LoggingSystem$Factory#PRESENT set to false at build time
Field org.springframework.boot.logging.logback.LogbackLoggingSystem$Factory#PRESENT set to true at build time
Field org.springframework.cloud.bootstrap.TextEncryptorConfigBootstrapper#RSA_IS_PRESENT set to false at build time
Field org.springframework.web.servlet.view.InternalResourceViewResolver#jstlPresent set to false at build time
Field org.springframework.web.context.support.StandardServletEnvironment#jndiPresent set to true at build time
Field org.springframework.web.context.support.WebApplicationContextUtils#jsfPresent set to false at build time
Field org.springframework.web.context.request.RequestContextHolder#jsfPresent set to false at build time
Field org.springframework.context.event.ApplicationListenerMethodAdapter#reactiveStreamsPresent set to false at build time
Field org.springframework.boot.logging.logback.LogbackLoggingSystemProperties#JBOSS_LOGGING_PRESENT set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jaxb2Present set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jackson2Present set to true at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jackson2XmlPresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jackson2SmilePresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#gsonPresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jsonbPresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#kotlinSerializationCborPresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#kotlinSerializationJsonPresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#kotlinSerializationProtobufPresent set to false at build time
Field org.springframework.boot.autoconfigure.web.format.WebConversionService#JSR_354_PRESENT set to false at build time
Field org.springframework.core.ReactiveAdapterRegistry#reactorPresent set to false at build time
Field org.springframework.core.ReactiveAdapterRegistry#rxjava3Present set to false at build time
Field org.springframework.core.ReactiveAdapterRegistry#kotlinCoroutinesPresent set to false at build time
Field org.springframework.core.ReactiveAdapterRegistry#mutinyPresent set to false at build time
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
Field org.springframework.web.servlet.mvc.method.annotation.ReactiveTypeHandler#isContextPropagationPresent set to false at build time
Field org.springframework.web.client.RestTemplate#romePresent set to false at build time
Field org.springframework.web.client.RestTemplate#jaxb2Present set to false at build time
Field org.springframework.web.client.RestTemplate#jackson2Present set to true at build time
Field org.springframework.web.client.RestTemplate#jackson2XmlPresent set to false at build time
Field org.springframework.web.client.RestTemplate#jackson2SmilePresent set to false at build time
Field org.springframework.web.client.RestTemplate#jackson2CborPresent set to false at build time
Field org.springframework.web.client.RestTemplate#gsonPresent set to false at build time
Field org.springframework.web.client.RestTemplate#jsonbPresent set to false at build time
Field org.springframework.web.client.RestTemplate#kotlinSerializationCborPresent set to false at build time
Field org.springframework.web.client.RestTemplate#kotlinSerializationJsonPresent set to false at build time
Field org.springframework.web.client.RestTemplate#kotlinSerializationProtobufPresent set to false at build time
Field org.springframework.web.servlet.support.RequestContext#jstlPresent set to false at build time
[2/7] Performing analysis...  [***********]                                                    (105.7s @ 1.58GB)
  18,216 (92.48%) of 19,698 classes reachable
  30,664 (68.78%) of 44,581 fields reachable
  90,657 (61.00%) of 148,606 methods reachable
     843 classes,   205 fields, and 3,909 methods registered for reflection
      64 classes,    70 fields, and    55 methods registered for JNI access
       4 native libraries: dl, pthread, rt, z
[3/7] Building universe...                                                                       (8.8s @ 1.60GB)
[4/7] Parsing methods...      [***]                                                              (6.8s @ 2.23GB)
[5/7] Inlining methods...     [****]                                                             (3.8s @ 1.84GB)
[6/7] Compiling methods...    [*******]                                                         (55.5s @ 2.28GB)
[7/7] Creating image...                                                                         (10.4s @ 2.19GB)
  38.23MB (48.53%) for code area:    58,807 compilation units
  37.43MB (47.50%) for image heap:  409,428 objects and 382 resources
   3.13MB ( 3.97%) for other data
  78.79MB in total
----------------------------------------------------------------------------------------------------------------
Top 10 packages in code area:                           Top 10 object types in image heap:
   1.64MB sun.security.ssl                                 8.47MB byte[] for code metadata
   1.11MB com.alibaba.nacos.shaded.com.google.protobuf     4.34MB java.lang.Class
   1.05MB java.util                                        3.98MB java.lang.String
 832.54KB java.lang.invoke                                 3.63MB byte[] for embedded resources
 718.00KB com.sun.crypto.provider                          3.44MB byte[] for java.lang.String
 540.44KB org.apache.catalina.core                         3.15MB byte[] for general heap data
 510.83KB java.lang                                        1.53MB com.oracle.svm.core.hub.DynamicHubCompanion
 499.61KB org.apache.tomcat.util.net                     975.30KB byte[] for reflection metadata
 490.43KB org.apache.coyote.http2                        796.93KB java.lang.String[]
 479.00KB java.util.concurrent                           736.08KB java.util.HashMap$Node
  30.03MB for 768 more packages                            5.93MB for 3371 more object types
----------------------------------------------------------------------------------------------------------------
                    9.8s (4.7% of total time) in 70 GCs | Peak RSS: 4.43GB | CPU load: 6.12
----------------------------------------------------------------------------------------------------------------
Produced artifacts:
 /home/jmc/demo4/target/demo4 (executable)
 /home/jmc/demo4/target/demo4.build_artifacts.txt (txt)
================================================================================================================
Finished generating 'demo4' in 3m 27s.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  03:30 min
[INFO] Finished at: 2023-01-01T18:30:37+08:00
[INFO] ------------------------------------------------------------------------
ruansheng8 commented 1 year ago

hello , you need to run the app with the tracing agent and generate the config temporarily in src/main/resources

  1. java -DspringAot=true -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image -jar target/myapp-0.0.1-SNAPSHOT.jar

when the app is started , use CTRL + C to shutdown it , and you will see the following automatically generated files

image

  1. mvn -Pnative native:compile
KillerJmc commented 1 year ago

@ruansheng8 Thank you! After I used this method, it worked successfully on both Ubuntu and Windows. Could you add this reflect information automatically while runing mvn -Pnative native:compile in next release version?

steverao commented 1 year ago

@ruansheng8 Thank you! After I used this method, it worked successfully on both Ubuntu and Windows. Could you add this reflect information automatically while runing mvn -Pnative native:compile in next release version?

Do you mean to add the corresponding reflection file? This file needs to be generated according to your application, so there is no way to add default files.

ruansheng8 commented 1 year ago

@KillerJmc Most components are currently not compatible with AOT, it may be a better choice to use agent to generate reflection files in the short term.

KillerJmc commented 1 year ago

@ruansheng8 Oh, I see. I hope Nacos and the other components can support AOT soon. Thank you for your hard work!

KillerJmc commented 1 year ago

Do you mean to add the corresponding reflection file? This file needs to be generated according to your application, so there is no way to add default files.

@steverao No. I mean add AOT support in Nacos project config files which related to AOT info generation using Spring Native API.

ruansheng8 commented 1 year ago

@ruansheng8 Thank you! After I used this method, it worked successfully on both Ubuntu and Windows. Could you add this reflect information automatically while runing mvn -Pnative native:compile in next release version?

Using RuntimeHintsRegistrar may solve this problem, but it will take some time to analyze the part of each component that needs to be supported by AOT

KillerJmc commented 1 year ago

Using RuntimeHintsRegistrar may solve this problem, but it will take some time to analyze the part of each component that needs to be supported by AOT

@ruansheng8 Yes, the reflection information analysis is easy for graalvm but consumes runtime. If we don't solve it in this way, It is harder for us to write common config files which can include all the classes we need in runtime and make sure it costs less runtime than using graalvm to analyse directly. There may exist an easier way to solve this problem...

karl-chanel commented 1 year ago

ORACLE官方有一个graalvm-reachability-metadata库,用来维护各个开发者把自己维护的库的AOT配置上传上去,在运行mvn -Pnative native:compile 时除去自己可以用RuntimeHintsRegistrar注册配置外会默认拉取这个repo里的配置信息,nacos 只要把自己的配置信息整理出来提交到这个repo就行了 @ruansheng8

ruansheng8 commented 1 year ago

ORACLE官方有一个graalvm-reachability-metadata库,用来维护各个开发者把自己维护的库的AOT配置上传上去,在运行mvn -Pnative native:compile 时除去自己可以用RuntimeHintsRegistrar注册配置外会默认拉取这个repo里的配置信息,nacos 只要把自己的配置信息整理出来提交到这个repo就行了 @ruansheng8

graalvm-reachability-metadata 这块内容目前社区已经在整理了,后续会和其他相关社区一起将对应的配置上传过去

karl-chanel commented 1 year ago

@ruansheng8 其他相关社区是指SPRING CLOUD ALIBABA的其他组件的client端吗,还有就是nacos server 之后有发布native image版本的计划吗

ruansheng8 commented 1 year ago

@karl-chanel 是的, 包括SCA项目集成的相关项目, SCA这边会对相关的starter模块进行native支持, 至于Nacos Server的Native Image相关版本发布计划由Nacos社区那边进行.

steverao commented 1 year ago

@ruansheng8 其他相关社区是指SPRING CLOUD ALIBABA的其他组件的client端吗,还有就是nacos server 之后有发布native image版本的计划吗

最终的形态应该是SCA这则仅采集自身模块源代码中的动态特性,将其组织成为配置文件上传到Oracle的metadata仓库,SCA中其他组件,比如Nacos/Sentinel/Seata/RocketMQ项目客户端的动态特性配置文件需要由相关社区去采集与上传,因为他们的客户端不仅仅只是被SCA项目所依赖,其他也有用户直接使用的其客户端,所以他们自己维护和处理是很有必要的。这块社区后续会跟相关社区同步相关意见,不过你个人作为用户,比较着急的话你也可以给相关社区留言。

karl-chanel commented 7 months ago

mark

github-actions[bot] commented 2 months ago

This issue has been open 30 days with no activity. This will be closed in 7 days.