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 356 forks source link

Spring cloud config example - unable to find entry point #285

Closed itzikiusa closed 4 years ago

itzikiusa commented 4 years ago

Hi, tried to run the example of 'cloud' from samples module getting the following error(graal 2.2.0 install) both when running from the IDE and both from build script:


Error: Main entry point class 'com.example.webflux.WebfluxApplication' not found.`
aclement commented 4 years ago

I just tried it:

-> native-image --version
GraalVM Version 20.2.0 (Java Version 1.8.0_262)
/home/andy/gits/spring-graalvm-native/spring-graalvm-native-samples/cloud [git:master:635baf0:]         
-> ./build.sh            
=== Building cloud sample ===
Packaging cloud with Maven
Unpacking cloud-0.0.1-SNAPSHOT.jar
Compiling cloud with GraalVM Version 20.2.0 (Java Version 1.8.0_262)
SUCCESS
Testing executable 'cloud'
SUCCESS
Build memory: 7.76GB
Image build time: 79.3s
RSS memory: 114.1M
Image size: 63.4M
Startup time: 0.141 (JVM running for 0.143)

which OS are you on? Are you building it build.sh when you say scripts?

Does the base project build fine for you? mvn clean package since that produces the built artifact (with the application class in) that the scripts will dismantle. mvn spring-boot:build-image also worked for me to create a docker image.

itzikiusa commented 4 years ago

Ubuntu 16.4 Graalvm 20.2.0 Java 8

sdeleuze commented 4 years ago

@itzikiusa Could you please provide the output of native-image --version, build.sh and mvn spring-boot:build-image?

itzikiusa commented 4 years ago

@sdeleuze @aclement just cloned the repo and ran the build.sh


=== Building cloud sample ===
Packaging cloud with Maven
./compile.sh: line 15: mvn: command not found
Unpacking cloud-0.0.1-SNAPSHOT.jar
cp: cannot stat 'META-INF': No such file or directory
find: 'BOOT-INF/lib': No such file or directory
Compiling cloud with GraalVM Version 20.2.0 (Java Version 1.8.0_262)
[cloud:6456]    classlist:   5,761.34 ms,  1.09 GB
Error: Main entry point class 'com.example.webflux.WebfluxApplication' not found.
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Error: Image build request failed with exit status 1

real    0m7.024s
user    0m22.572s
sys 0m1.892s
FAILURE: an error occurred when compiling the native-image.`
itzikiusa commented 4 years ago

this is when trying to run via mvn build


[INFO] Building image 'docker.io/library/cloud:0.0.1-SNAPSHOT'
[INFO]
[INFO]  > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 3%
[INFO]  > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 6%
[INFO]  > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 8%
[INFO]  > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 9%
[INFO]  > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 12%
[INFO]  > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 20%
[INFO]  > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 29%
[INFO]  > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 37%
[INFO]  > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 44%
[INFO]  > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 48%
[INFO]  > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 51%
[INFO]  > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 59%
[INFO]  > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 65%
[INFO]  > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 100%
[INFO]  > Pulled builder image 'gcr.io/paketo-buildpacks/builder@sha256:48382899b4c5b4d8ba143dc5b8c9f64d0c89814a2bff1cd79c30da1534120ee6'
[INFO]  > Pulling run image 'docker.io/paketobuildpacks/run:base-cnb' 0%
[INFO]  > Pulling run image 'docker.io/paketobuildpacks/run:base-cnb' 38%
[INFO]  > Pulling run image 'docker.io/paketobuildpacks/run:base-cnb' 100%
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  50.265 s
[INFO] Finished at: 2020-09-18T18:46:37Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.4.0-M3:build-image (default-cli) on project cloud: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.4.0-M3:build-image failed: No digest found -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException`
sdeleuze commented 4 years ago

I tested locally and it works.

For build-image I see a strange Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.4.0-M3:build-image failed: No digest found -> [Help 1] error.

For the script, please install Maven locally to avoid mvn: command not found or modify the script to use ./mvnw instead of mvn and share the output.

itzikiusa commented 4 years ago

just ran it again seems to work now, cannot reproduce it :(