Spring Devtools Live reload in Docker ist not working

189 Views Asked by At

I've tried to configure the live reload in spring boot application, using Intellij and Docker, but this is not working.

IDE: IntelliJ IDEA 2023.1.2 (Community Edition)
OS: Ubuntu 22.04
Open JDK: 20.0.1

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.1.1</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.coding4world</groupId>
    <artifactId>user-api</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>user-api</name>
    <description>User API</description>
    <properties>
        <java.version>20</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludeDevtools>false</excludeDevtools>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

application.properties

#local environment configuration
spring.devtools.remote.secret=mysecret

dockerfile (I tried to generate the image with spring-boot:build-image too, but it didn't work too)

FROM eclipse-temurin:20.0.1_9-jre-alpine@sha256:a0c54e367b648e585722fc6e8d69361ad54bafdc5b89584da987b996b035fb11
WORKDIR /opt/app
RUN addgroup --system javauser && adduser -S -s /usr/sbin/nologin -G javauser javauser
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
RUN chown -R javauser:javauser .
USER javauser
ENTRYPOINT ["java", "-jar", "app.jar"]

RemoteSpringApplication

Error:

2023-06-23T20:37:35.011931163Z Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: A child container failed during start
2023-06-23T20:37:35.011932745Z  at java.base/java.util.concurrent.FutureTask.report(Unknown Source) ~[na:na]
2023-06-23T20:37:35.011934197Z  at java.base/java.util.concurrent.FutureTask.get(Unknown Source) ~[na:na]
2023-06-23T20:37:35.011935667Z  at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:873) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.011937223Z  ... 30 common frames omitted
2023-06-23T20:37:35.011938668Z Caused by: org.apache.catalina.LifecycleException: A child container failed during start
2023-06-23T20:37:35.011940173Z  at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:885) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.011942895Z  at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:846) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.011944542Z  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.011946041Z  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1328) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.011947551Z  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1318) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.011949077Z  at java.base/java.util.concurrent.FutureTask.run(Unknown Source) ~[na:na]
2023-06-23T20:37:35.011950615Z  at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.011952166Z  at java.base/java.util.concurrent.AbstractExecutorService.submit(Unknown Source) ~[na:na]
2023-06-23T20:37:35.011953988Z  at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.011955568Z  ... 30 common frames omitted
2023-06-23T20:37:35.011957013Z Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.StandardRoot@44d4d992]
2023-06-23T20:37:35.011958596Z  at java.base/java.util.concurrent.FutureTask.report(Unknown Source) ~[na:na]
2023-06-23T20:37:35.011960077Z  at java.base/java.util.concurrent.FutureTask.get(Unknown Source) ~[na:na]
2023-06-23T20:37:35.011962845Z  at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:873) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.011964383Z  ... 38 common frames omitted
2023-06-23T20:37:35.011965805Z Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.StandardRoot@44d4d992]
2023-06-23T20:37:35.011967334Z  at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.011968872Z  at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:139) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.011970357Z  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:173) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.011971860Z  at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4567) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.011973421Z  at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4700) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.011974933Z  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.011976480Z  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1328) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.011977994Z  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1318) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.011979522Z  at java.base/java.util.concurrent.FutureTask.run(Unknown Source) ~[na:na]
2023-06-23T20:37:35.011981295Z  at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.011982896Z  at java.base/java.util.concurrent.AbstractExecutorService.submit(Unknown Source) ~[na:na]
2023-06-23T20:37:35.011985477Z  at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.011987728Z  ... 38 common frames omitted
2023-06-23T20:37:35.011990058Z Caused by: java.lang.Error: factory already defined
2023-06-23T20:37:35.011992165Z  at java.base/java.net.URL.setURLStreamHandlerFactory(Unknown Source) ~[na:na]
2023-06-23T20:37:35.011993665Z  at org.apache.catalina.webresources.TomcatURLStreamHandlerFactory.<init>(TomcatURLStreamHandlerFactory.java:121) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.011995336Z  at org.apache.catalina.webresources.TomcatURLStreamHandlerFactory.getInstanceInternal(TomcatURLStreamHandlerFactory.java:52) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.011996896Z  at org.apache.catalina.webresources.TomcatURLStreamHandlerFactory.register(TomcatURLStreamHandlerFactory.java:73) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.011998451Z  at org.apache.catalina.webresources.StandardRoot.registerURLStreamHandlerFactory(StandardRoot.java:699) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.012001313Z  at org.apache.catalina.webresources.StandardRoot.initInternal(StandardRoot.java:686) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.012002843Z  at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136) ~[tomcat-embed-core-10.1.10.jar!/:na]
2023-06-23T20:37:35.012004347Z  ... 48 common frames omitted

I was trying to configure reload live of my spring boot application in docker and intellij.

0

There are 0 best solutions below