We are building a Docker image for a Java + Maven project that runs a Spring Boot application using Kafka.
When we build the image on Windows and run the container on a Linux server, everything works fine. However, when we build the image on Linux and run it on the same Linux server, it fails with the following 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
We made sure that:
We are using the same version of Docker on both Windows and Linux. Our Maven build process produces the correct .jar file in both environments. We are working in a closed network, so we cannot share code.
What could be causing this issue, and how can we debug it further?
We are building a Docker image for a Java + Maven project that runs a Spring Boot application using Kafka.
When we build the image on Windows and run the container on a Linux server, everything works fine. However, when we build the image on Linux and run it on the same Linux server, it fails with the following 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
We made sure that:
We are using the same version of Docker on both Windows and Linux. Our Maven build process produces the correct .jar file in both environments. We are working in a closed network, so we cannot share code.
What could be causing this issue, and how can we debug it further?
Share Improve this question asked Mar 20 at 12:05 Amit YaariAmit Yaari 12 Answers
Reset to default -1Possible Causes & Quick Checks:
Line Endings (CRLF vs LF):
Files from Windows may have\r\n
line endings.
→ Rundos2unix
on configs & scripts.File Permissions:
Linux might lack execute permissions.
→ Addchmod +x
to scripts & check permissions in Dockerfile.Case Sensitivity:
Windows is case-insensitive, Linux isn't.
→ Double-check file, package, or config names.Different Base Image/JDK:
Make sure you're using the same base image in Dockerfile on both systems.Kafka Streams State Dir Permissions:
Kafka may fail writing to/tmp
.
→ Set:
spring.kafka.streams.state.dir=/tmp/stream-state
and ensure correct permissions.Debug:
Enable debug logging:
logging.level..springframework.kafka=DEBUG
Compare built images:
docker run --rm yourimage ls -lR /app
Although you've mentioned that the JAR appears to be correct, its worth checking/comparing the BOOT-INF/classes
and BOOT-INF/lib
directories inside the JAR to confirm that dependencies and classes are properly included.
https://stackoverflow/a/57034217/14128110