Unable to shutdown Tomcat because of port in use

Was having an annoying problem where I could not shutdown a running tomcat instance.

The below is the shutdown issue I was facing:

> $CATALINA_HOME/bin/shutdown.sh
Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 9999; nested exception is:
java.net.BindException: Address already in use

A work-around (bad one by the way) was to just kill the catalina process:
> ps -A | grep catalina
> kill <port number>

However, I finally figured it out. Turns out switching on jmxremote (Java remote console memory monitoring) within catalina.sh was to blame. I’m not using remote monitoring anymore, so I just removed the following red entry from $CATALINA_HOME/bin/catalina.sh JAVA_OPTS line:

JAVA_OPTS=”$JAVA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager”

Try that and see if it works!

Advertisements

2 thoughts on “Unable to shutdown Tomcat because of port in use

  1. Why not just run ‘netstat -tupan | grep :9999’ to see what process is using that port? Besides editing your JAVA_OPTS variable, you can also specify exit ports explicitly in the Tomcat instance’s server.xml.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s