spring-attic / spring-native

Spring Native is now superseded by Spring Boot 3 official native support
https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html
Apache License 2.0
2.74k stars 355 forks source link

Spring Boot Native Boot Up Problems #1654

Closed fragaLY closed 2 years ago

fragaLY commented 2 years ago

Hello, colleagues,

I faced a problem of booting up the native image. It has no logs at all.

Could you please help me to find a workaround?

Hardware Overview: Model Name: MacBook Pro Model Identifier: MacBookPro16,2 Processor Name: Quad-Core Intel Core i7 Processor Speed: 2,3 GHz Number of Processors: 1 Total Number of Cores: 4 L2 Cache (per Core): 512 KB L3 Cache: 8 MB Hyper-Threading Technology: Enabled Memory: 32 GB OS: v 12.4 Monterey

The Sample: https://github.com/fragaLY/performance-researches/tree/master/spring-boot-web-native

Steps to reproduce Firstly run from "docker" directory: docker-compose up

Then ./gradlew bootBuildImage docker run -p 8080:8080 spring-boot-web-native:0.0.1-SNAPSHOT

The process is killed.

Thank you in advance.

mhalbritter commented 2 years ago

Hi! Do you happen to have any logs?

fragaLY commented 2 years ago

@mhalbritter , as I said "It has no logs at all." Unfortunately, the only thing is to try to find the way on the sys level. Nevertheless, all the tools I've used had no any option to help me in research.

fragaLY commented 2 years ago

Hi! Do you happen to have any logs?

If you need any help from my side, I am opened for contribution.

fragaLY commented 2 years ago

gdb says:

image

Thank you for advice, @kharkevich.

mhalbritter commented 2 years ago

Okay, I can reproduce it locally. The generated native image doesn't log anything and exits with exit code 1.

The problem seems to be the logback-spring.xml file, which prevents logging. As soon this is removed, you can see this:

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is java.lang.NoSuchMethodError: io.undertow.util.FastConcurrentDirectDeque.<init>()
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:165) ~[spring-boot-web-native:2.7.1]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577) ~[spring-boot-web-native:5.3.21]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-web-native:2.7.1]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-web-native:2.7.1]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-web-native:2.7.1]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-web-native:2.7.1]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-web-native:2.7.1]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-web-native:2.7.1]
        at by.vk.springbootwebnative.SpringBootWebNativeApplication.main(SpringBootWebNativeApplication.java:10) ~[spring-boot-web-native:na]
Caused by: java.lang.NoSuchMethodError: io.undertow.util.FastConcurrentDirectDeque.<init>()
        at io.undertow.util.ConcurrentDirectDeque.<clinit>(ConcurrentDirectDeque.java:45) ~[spring-boot-web-native:2.2.18.Final]
        at io.undertow.server.handlers.cache.LRUCache.<init>(LRUCache.java:67) ~[na:na]
        at io.undertow.servlet.handlers.ServletPathMatches.<init>(ServletPathMatches.java:82) ~[spring-boot-web-native:2.2.18.Final]
        at io.undertow.servlet.core.DeploymentImpl.<init>(DeploymentImpl.java:95) ~[na:na]
        at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:151) ~[na:na]
        at org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory.createManager(UndertowServletWebServerFactory.java:330) ~[spring-boot-web-native:2.7.1]
        at org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory.getWebServer(UndertowServletWebServerFactory.java:299) ~[spring-boot-web-native:2.7.1]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:184) ~[spring-boot-web-native:2.7.1]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:162) ~[spring-boot-web-native:2.7.1]
        ... 8 common frames omitted

You are using Undertow, for which spring-native has no support for. Please see the list of supported starters for more details.

fragaLY commented 2 years ago

Thank you, @mhalbritter

Have a nice day.

mhalbritter commented 2 years ago

You're welcome! Have a nice day, too!