0

I'm trying to containerise a Java Spring Boot application using Maven and Docker, but my build consistently fails inside the Docker container at the maven-resources-plugin step with the error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources) on project my-app: Function not implemented -> [Help 1]

I am setting up this project on a new hosted server. I have manually installed Docker, Maven, and Java at the system root level.

Project setup

I have the following Dockerfile:

FROM maven:3.9.0-eclipse-temurin-19 AS MAVEN_BUILD
COPY pom.xml /build/
COPY src /build/src/
WORKDIR /build/
RUN mvn dependency:resolve
RUN mvn clean package -Pdocker

FROM eclipse-temurin:19
COPY --from=MAVEN_BUILD /build/target/my-app-1.0-SNAPSHOT.jar /app/
EXPOSE 8082
ENTRYPOINT ["java", "--add-opens", "java.base/java.time=ALL-UNNAMED", "-jar", "/app/my-app-1.0-SNAPSHOT.jar"]

pom.xml file:

<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 http://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>2.7.4</version>
    </parent>

    <groupId>com.my.app</groupId>
    <artifactId>My-App-Service</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <properties>
        <maven.compiler.source>19</maven.compiler.source>
        <maven.compiler.target>19</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <!-- Include other dependencies as necessary -->
    </dependencies>

    <profiles>
        <profile>
            <id>docker</id>
            <properties>
                <env>docker</env>
            </properties>
        </profile>
    </profiles>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

What I have tried

  1. Verified it works locally:

    • Running mvn clean package outside Docker (on my machine) works fine.
    • Running the Maven project build outside Docker on the hosted server also works fine.
    • Building the Dockerized project locally also works without any issues.
  2. Checked for missing dependencies:

    • I tried adding mvn dependency:resolve before mvn clean package.

This is a new setup for me, and I'm trying to troubleshoot this issue with the resources available. Since I am moving the project from one server to another, I would prefer not to make changes to the Dockerfile, as it was working fine on the previous server.

3
  • Can you try a newer version of the base image for your build (maven:3.9.0-eclipse-temurin-19) - both using a newer Maven version and a newer JDK version (19 isn't supported any more by many vendors) Commented Mar 8 at 10:20
  • Apart from that, you might want to try explicitly specifying the version of the Maven resources plugin (in the <plugins> or <pluginManagement> section) to either something newer or older. Commented Mar 8 at 10:21
  • After trying out the suggestions, adding the maven-resources-plugin (3.3.0) in the pom.xml worked. Commented Mar 10 at 7:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.