OlgaMaciaszek / native-eureka-client

Eureka Discovery Client with Spring Native
3 stars 2 forks source link

Eureka server cannot start successfully even if Spring Native succeed in building #1

Open xixiangzouyibian opened 1 year ago

xixiangzouyibian commented 1 year ago

I'm trying to build Eureka Server with Spring Native for research. The build was sucessful, but got failure when ran executable file:

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:165) ~[eureka-service:2.7.7]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577) ~[eureka-service:5.3.24]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[eureka-service:2.7.7]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731) ~[eureka-service:2.7.7]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[eureka-service:2.7.7]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) ~[eureka-service:2.7.7]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) ~[eureka-service:2.7.7]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) ~[eureka-service:2.7.7]
        at com.martin.eureka.EurekaServiceApplication.main(EurekaServiceApplication.java:28) ~[eureka-service:na]
....
Caused by: java.lang.ExceptionInInitializerError: null
        at org.springframework.cloud.netflix.eureka.server.ContextBootstrapInitializer.lambda$registerEurekaServerAutoConfiguration$12(ContextBootstrapInitializer.java:64) ~[na:na]
        at org.springframework.aot.beans.factory.BeanDefinitionRegistrar$ThrowableFunction.apply(BeanDefinitionRegistrar.java:294) ~[eureka-service:0.12.2]
        at org.springframework.aot.beans.factory.BeanDefinitionRegistrar.lambda$instanceSupplier$0(BeanDefinitionRegistrar.java:115) ~[na:na]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1249) ~[eureka-service:5.3.24]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1191) ~[eureka-service:5.3.24]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[eureka-service:5.3.24]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[eureka-service:5.3.24]
        ... 88 common frames omitted
Caused by: java.lang.NullPointerException: null
        at org.springframework.util.ReflectionUtils.makeAccessible(ReflectionUtils.java:788) ~[na:na]
        at org.springframework.cloud.netflix.eureka.server.CloudJacksonJson$CloudJacksonCodec.setField(CloudJacksonJson.java:150) ~[na:na]
        at org.springframework.cloud.netflix.eureka.server.CloudJacksonJson$CloudJacksonCodec.<init>(CloudJacksonJson.java:137) ~[na:na]
        at org.springframework.cloud.netflix.eureka.server.CloudJacksonJson.<init>(CloudJacksonJson.java:56) ~[na:na]
        at org.springframework.cloud.netflix.eureka.server.EurekaServerAutoConfiguration.<clinit>(EurekaServerAutoConfiguration.java:109) ~[eureka-service:3.1.4]
        ... 95 common frames omitted

Build Version:

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /home/martin/.sdkman/candidates/maven/current
Java version: 11.0.17, vendor: BellSoft, runtime: /home/martin/.sdkman/candidates/java/22.3.r11-nik
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.15.0-60-generic", arch: "amd64", family: "unix"

Build Log:

[1/7] Initializing...                                                                                   (20.2s @ 0.52GB)
 Version info: 'GraalVM 22.3.0 Java 11 CE'
 Java version info: '11.0.17+7-LTS'
 C compiler: gcc (linux, x86_64, 9.4.0)
 Garbage collector: Serial GC
 1 user-specific feature(s)
 - com.oracle.svm.thirdparty.gson.GsonFeature
Warning: Could not register complete reflection metadata for org.springframework.validation.beanvalidation.SpringValidatorAdapter$ViolationFieldError. Reason(s): java.lang.NoClassDefFoundError: javax/validation/Validator
[2/7] Performing analysis...  [*********]                                                               (81.3s @ 3.18GB)
  23,732 (90.90%) of 26,108 classes reachable
  39,950 (73.76%) of 54,159 fields reachable
 111,320 (63.67%) of 174,844 methods reachable
   1,171 classes,   259 fields, and 5,744 methods registered for reflection
     133 classes,   223 fields, and   113 methods registered for JNI access
       8 native libraries: dl, freetype, m, pthread, rt, stdc++, z
[3/7] Building universe...                                                                               (9.4s @ 4.34GB)
[4/7] Parsing methods...      [***]                                                                      (7.7s @ 3.66GB)
[5/7] Inlining methods...     [***]                                                                      (3.2s @ 4.25GB)
[6/7] Compiling methods...    [[6/7] Compiling methods...    [******]                                                                  (38.3s @ 3.44GB)
[7/7] Creating image...                                                                                  (9.5s @ 4.61GB)
  47.01MB (48.75%) for code area:    70,822 compilation units
  44.14MB (45.77%) for image heap:  479,318 objects and 177 resources
   5.28MB ( 5.48%) for other data
  96.43MB in total
------------------------------------------------------------------------------------------------------------------------
Top 10 packages in code area:                               Top 10 object types in image heap:
   1.57MB sun.security.ssl                                    10.24MB byte[] for code metadata
   1.54MB freemarker.core                                      5.67MB java.lang.Class
   1.09MB java.util                                            4.63MB java.lang.String
 758.21KB com.sun.proxy                                        4.12MB byte[] for java.lang.String
 674.86KB com.sun.crypto.provider                              3.77MB byte[] for general heap data
 644.93KB org.apache.tomcat.util.net                           2.97MB byte[] for embedded resources
 546.62KB org.apache.catalina.core                             2.17MB com.oracle.svm.core.hub.DynamicHubCompanion
 496.71KB org.apache.coyote.http2                              1.25MB byte[] for reflection metadata
 493.03KB java.util.concurrent                               938.83KB java.lang.String[]
 484.26KB sun.security.x509                                  839.22KB c.o.svm.core.hub.DynamicHub$ReflectionMetadata
  38.29MB for 1049 more packages                               6.65MB for 3078 more object types
------------------------------------------------------------------------------------------------------------------------
                        11.7s (6.5% of total time) in 59 GCs | Peak RSS: 6.82GB | CPU load: 4.97
------------------------------------------------------------------------------------------------------------------------
Produced artifacts:
 /home/martin/eureka-service/target/eureka-service (executable)
 /home/martin/eureka-service/target/eureka-service.build_artifacts.txt (txt)
========================================================================================================================
Finished generating 'eureka-service' in 2m 59s.

Could you please advice for this ?

xixiangzouyibian commented 1 year ago

Aslo attach my maven pom profile:

  <profiles>
    <profile>
      <id>native</id>
      <dependencies>
        <!-- Required with Maven Surefire 2.x -->
        <dependency>
          <groupId>org.junit.platform</groupId>
          <artifactId>junit-platform-launcher</artifactId>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.springframework.experimental</groupId>
          <artifactId>spring-native</artifactId>
          <version>0.12.2</version>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.springframework.experimental</groupId>
            <artifactId>spring-aot-maven-plugin</artifactId>
            <version>0.12.2</version>
            <executions>
              <execution>
                <id>generate</id>
                <goals>
                  <goal>generate</goal>
                </goals>
              </execution>
              <execution>
                <id>test-generate</id>
                <goals>
                  <goal>test-generate</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
              <image>
                <builder>paketobuildpacks/builder:tiny</builder>
                <env>
                  <BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
                </env>
              </image>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.graalvm.buildtools</groupId>
            <artifactId>native-maven-plugin</artifactId>
            <version>0.9.13</version>
            <extensions>true</extensions>
            <executions>
              <execution>
                <id>build-native</id>
                <goals>
                  <goal>build</goal>
                </goals>
                <phase>package</phase>
              </execution>
<!--              <execution>
                <id>test-native</id>
                <goals>
                  <goal>test</goal>
                </goals>
                <phase>test</phase>
              </execution>-->
            </executions>
            <configuration>
              <!-- ... -->
              <skipNativeTests>true</skipNativeTests>
            </configuration>
          </plugin>
          <!-- Avoid a clash between Spring Boot repackaging and native-maven-plugin -->
          <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
              <classifier>exec</classifier>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>