mvn installed @image runtime but port confilct @ azure conatiner app

M. A 0 Reputation points
2024-09-02T17:09:32.9366667+00:00

i am installing mvn in an image that is pushed to azure container app everything works as it should locally by running the code on the ide and the jar and the docker run but in azure it is not it is giving an address used exception whether i run the programmatic mvn or i run on the container console here is my dockerfile

# Use an official Maven image with OpenJDK to build the application
FROM maven AS build

# Set the working directory in the container
WORKDIR /app

# Copy the project files into the container
COPY . .
# List files to verify the copy
RUN ls -la /app
# Build the application using Maven
RUN mvn clean package

# Use an official OpenJDK runtime as a parent image
FROM openjdk:17-jdk-alpine

# Install Maven
RUN apk add --no-cache maven

# Set the working directory in the container
WORKDIR /app

# Copy the JAR file from the build stage
COPY --from=build /app/target/xxx.jar xxxApp.jar

# Expose the port your Spring Boot app runs on
EXPOSE 8080


# Run the Spring Boot application
ENTRYPOINT ["java", "-jar", "xxx.jar"]

Here is the error

/app # mvn clean
Picked up JAVA_TOOL_OPTIONS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=24000 -Dcom.sun.management.jmxremote.local.only=true -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=127.0.0.1
Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 24000; nested exception is: 
        java.net.BindException: Address in use
jdk.internal.agent.AgentConfigurationError: java.rmi.server.ExportException: Port already in use: 24000; nested exception is: 
        java.net.BindException: Address in use
        at jdk.management.agent/sun.management.jmxremote.ConnectorBootstrap.startRemoteConnectorServer(ConnectorBootstrap.java:493)
        at jdk.management.agent/jdk.internal.agent.Agent.startAgent(Agent.java:447)
        at jdk.management.agent/jdk.internal.agent.Agent.startAgent(Agent.java:599)
Caused by: java.rmi.server.ExportException: Port already in use: 24000; nested exception is: 
        java.net.BindException: Address in use
        at java.rmi/sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:346)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:243)
        at java.rmi/sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:412)
        at java.rmi/sun.rmi.transport.LiveRef.exportObject(LiveRef.java:147)
        at java.rmi/sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:232)
        at java.rmi/sun.rmi.registry.RegistryImpl.setup(RegistryImpl.java:220)
        at java.rmi/sun.rmi.registry.RegistryImpl.
Azure Container Apps
Azure Container Apps
An Azure service that provides a general-purpose, serverless container platform.
399 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.