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!
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.
Thanks for the tip! Actually ended up using netstat to find out that jmxremote was still running.
What do you mean by exit ports?
Thanks again,
rishi