I'm running a Java application inside a Maven-based Docker image. When I run the container on Docker Desktop, I can:
Enter the container
Build a JAR using Maven (mvn package)
Run the JAR successfully with
java -jar myapp.jar
However, when I run the same Docker image on a Linux machine, I follow the exact same steps, but the JAR fails to run with the error:
Error creating bean with name 'someName' defined in URL [jar:nested:/app/target/kafka.jar/!BOOT-INF/classes/!/aggregations/processors/someName.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'someName2' defined in class path [/springframework/kafka/annotations/someName2.class]: Failed to instantiate [.springframework.kafka.config.someName2]: Factory method 'defaultKafkaStreamsBuilder' threw exception with message: null
What I've Checked So Far: The image is identical (same image ID in docker image ls).
The architecture is the same (uname -m
inside the container returns x86_64 in both environments).
Java versions are identical (java -version
shows the same JDK version).
The JARs are completely identical (jar tvf myapp.jar
shows the same files and structure).
Maven versions are the same (mvn -version
is identical).
File permissions are the same (ls -l myapp.jar
confirms normal permissions).
Strange Discovery: If I build the JAR inside Docker Desktop, copy it to the Linux container, and run it → it works.
If I build the JAR inside the Linux container and try to run it → it fails.
What could cause a JAR file built inside the Linux container to fail while the same JAR, built inside Docker Desktop, works?