Describe the bug
Sadly trying to execute the quarkus backend in kubernetes results into the following error.
Executing the file on my local development machine works.
Maybe something in the gradle cache is missing?
Expected behavior
A working backend.
Actual behavior
In the jar file exist the files
Application.class -> 6.5 kB
Application$1.class -> 855 Bytes
Application$2.class -> 921 Bytes
Application$ShutdownHookThread.class -> 1,8 kB
Exception in thread "main" java.lang.NoClassDefFoundError: io/quarkus/runtime/Application
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:27)
Caused by: java.lang.ClassNotFoundException: io.quarkus.runtime.Application
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 10 more
To Reproduce
Steps to reproduce the behavior:
image 'gradle:6.0-jdk8'sh 'gradle clean quarkusBuild --uber-jar -x test -x buildNative -x testNative'FROM openjdk:8-jdk-slim
ENTRYPOINT ["java","-jar","build/*-runner.jar"]
Configuration
## Configuration file
## key = value
quarkus.datasource.driver=org.postgresql.Driver
%dev.quarkus.datasource.driver=org.h2.Driver
%test.quarkus.datasource.driver=org.h2.Driver
quarkus.datasource.url=jdbc:postgresql://${postgres.uri}:${postgres.port}/${postgres.db}
%dev.quarkus.datasource.url=jdbc:h2:mem:test
%test.quarkus.datasource.url=jdbc:h2:mem:test
quarkus.datasource.username=${postgres.user}
%dev.quarkus.datasource.username=xxx
%test.quarkus.datasource.username=xxx
quarkus.datasource.password=${postgres.password}
%dev.quarkus.datasource.password=xxx
%test.quarkus.datasource.password=xxx
# drop and create the database at startup (use `update` to only update the schema)
# development purposes or the project crash due to changes in the entities
quarkus.hibernate-orm.database.generation=update
%dev.quarkus.hibernate-orm.database.generation=drop-and-create
%test.quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.http.port=8005
quarkus.http.root-path=/xxx/api/v2
quarkus.kafka-streams.bootstrap-servers=xxx-kafka:9092
%dev.quarkus.kafka-streams.bootstrap-servers=localhost:9092
%test.quarkus.kafka-streams.bootstrap-servers=localhost:9092
quarkus.kafka-streams.application-id=quarkus-admin-backend
# quarkus.kafka-streams.client-id=1
quarkus.kafka-streams.topics=courses
%dev.quarkus.kafka-streams.topics=xxx-test
%test.quarkus.kafka-streams.topics=xxx-test
# pass-through options
kafka-streams.cache.max.bytes.buffering=10240
kafka-streams.commit.interval.ms=1000
kafka-streams.metadata.max.age.ms=500
kafka-streams.auto.offset.reset=earliest
kafka-streams.metrics.recording.level=DEBUG
Screenshots
Environment (please complete the following information):
uname -a or ver: 4.19.86-coreosjava -version: JDK 8Additional context
(Add any other context about the problem here.)
The same issue happened with the native image.
So both the native and the jvm image sharing something in common.
I use gradle and kotlin.
Same issue happened with 1.0.1.Final
The runner.jar is not a fat jar: you need to also include the lib/ directory.
See the default Dockerfiles you have in the src/main/docker of your application (if it has been generated).
Thank you
It generates a libs/ folder with s
Sadly that didn't change my issue copying it into the docker container
(Runner jar in root and libs folder with another single jar file in the same place)
If I remove everything in the build folder except the runner file , I can still execute the 65mb big runner file.
But you're sure that will be the issue @gsmet ?
No, I'm talking about a lib/ directory and you should have much more than one jar in it.
That being said, if your runner jar is 65 MB, maybe you are generating an uberjar? Hard to say without your config. If so, it should be self contained.
Can you check if the aforementioned class is in the jar?
Yes, I create an uber jar with gradle quarkusBuild --uber-jar as an attempt to fix this problem.
Another attempt was to create a native Image.
But every attempt ended with this error in the openJDK8 docker container in kubernetes, but with a working application on my local Linux machine with openJDK
Yes, the Application class files exist in the needed path inside the jar file
I listed the ones with the Name Application in the Actual Behaviour section above
Do I maybe a different build parameter to build it in container A with gradle and run it in container B with openJDK(fat/normal)/native ?
And which maybe important informative do you need from me?
If I download the built jar file and run it locally or in a local docker, it works.
If I run the same jar file in the kubernetes docker container with the same root image openjdk:8-jdk-slim
So the only difference between my local machine and the kubernetes docker container is the underlying host system.
Do the native/jvm(uber jar and normal) image needsomething outside of the container itself on the host system which may trigger this behaviour?
Here is the file content of the jar file.
@MartinX3 could you create a minimal reproducer that exhibits the said behavior? I'd like to take a look
I changed the project name in the project and build pipeline, now it works.
I am unable to reproduce it any more.
So I better close it.
Maybe someone will humble on this problem, too, then I can try to give help solving his problem.
Thank you all for trying to help me!
Most helpful comment
The runner.jar is not a fat jar: you need to also include the
lib/directory.See the default Dockerfiles you have in the
src/main/dockerof your application (if it has been generated).