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
Verified it works locally:
- Running
mvn clean packageoutside 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.
- Running
Checked for missing dependencies:
- I tried adding
mvn dependency:resolvebeforemvn clean package.
- I tried adding
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.
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)<plugins>or<pluginManagement>section) to either something newer or older.