Spring Boot layered jar with multiple databases gets stuck in docker container

  docker, java, spring-boot

I’ve been stuck on a problem for hours: I have a Spring Boot application that I run in a docker container. For this I use layered jars. This all worked fine. Then I had to change the application so that two databases (PostgreSQL) are configured. If I just run the jar file via java -jar, everything works fine. But as soon as I run the application in the container, it hangs without any error message or similar. Since the last log what I see on the console is :

2020-12-09 13:09:58.282 DEBUG 1 --- [           main] o.h.boot.internal.BootstrapContextImpl   : Injecting ScanOptions [[email protected]fedf1] into BootstrapContext; was [[email protected]a90ce]

After that nothing more happens. My docker file looks like this:

FROM amazoncorretto:11 as builder
COPY app.jar app.jar

RUN java -Djarmode=layertools -jar app.jar extract
FROM amazoncorretto:11
COPY --from=builder dependencies/ ./
COPY --from=builder snapshot-dependencies/ ./
RUN true
COPY --from=builder spring-boot-loader/ ./
COPY --from=builder application/ ./
ENTRYPOINT ["java","org.springframework.boot.loader.JarLauncher"]

Does anyone know what the problem is or where I can further search for the cause?

Best regards

Source: Docker Questions

One Reply to “Spring Boot layered jar with multiple databases gets stuck in docker container”

  • Hi,

    We stumbled on the same issue in our application. Our fix was to remove the hibernate/jpa specific starters from the project as we did not even have an entity in the application. It seems that Hibernate has an issue when scanning a package that does not contain at least 1 entity AND when running on a layered spring boot app iso a fat jar.
    An other solution of course would be to create a docker image with the fat jar if this is feasible for your.