Tomcat fails to stop with "Port already in use" when enabling jmx remote monitoring

Solution Verified - Updated -

Issue

We are setting the following java options to JAVA_OPTS in order to enable jmx remote monitoring:

JAVA_OPTS="$JAVA_OPTS -Xms1024m -Xmx2048m"
JAVA_OPTS="$JAVA_OPTS -XX:PermSize=256m -XX:MaxPermSize=256m"
JAVA_OPTS="$JAVA_OPTS -verbose:gc -Xloggc:gc.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps"
JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote=true"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=12345" 

Then the following error is shown when executing catalina.sh stop or service tomcat6 stop command:

Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 12345; nested exception is: 
    java.net.BindException: Address already in use

Then we have to stop Tomcat java process with kill command like: $kill <TOMCAT_JAVA_PID>

Environment

  • JBoss Enterprise Web Server (EWS)
    • Tomcat 5
    • Tomcat 6
    • Tomcat 7

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content