BowerStudios.com

  • My Lab
  • Family
  • Friends
  • Professional
  • About
Home

Port already in use error when trying to shutdown Apache Tomcat with JMX monitoring enabled

daniel —Mon, 08/02/2010 - 10:00am

  • Java
  • Groovy
  • Linux

So you tried to use JMX to monitor your Tomcat instance. You might have done so with the following lines in catalina.sh:

JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8085"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"

Everything started up nicely, and you were able to monitor. YAY!

But when you ran the shutdown script:

user@host:/apache-tomcat-6.0.26$ bin/shutdown.sh
Using CATALINA_BASE: /apache-tomcat-6.0.26
Using CATALINA_HOME: /apache-tomcat-6.0.26
Using CATALINA_TMPDIR: /apache-tomcat-6.0.26/temp
Using JRE_HOME: /usr/lib/jvm/java-6-sun
Using CLASSPATH: /apache-tomcat-6.0.26/bin/bootstrap.jar
Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 8085; nested exception is:
java.net.BindException: Address already in use

Only a kill -9 would bring down tomcat. Uh oh!

Setting these properties in JAVA_OPTS tries to start a jmx server when you start tomcat AND when you shutdown tomcat. Hence the port already in use exception. You need to set these properties for CATALINA_OPTS instead of JAVA_OPTS. This will only run when you start tomcat.

CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8999"
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"

hint from: itags

  • Log in to post comments

Navigation

  • Search
  • Recent content
  • Contact Me
  • Mail
  • Pass Hasher
  • Bower Studios Admin

Quotes

daniel —Thu, 02/14/2008 - 5:28pm

If you're not part of the solution, you're part of the precipitate.

—

Henry J. Tillman

  • Log in to post comments
  • daniel's quotes

Popular content

Last viewed:

  • Dealing with large files in VI
  • Nice Catalog of Optical and Visual Illusions
  • Encapsulation with closures (groovy)
  • Connect a Debugger to Tomcat from Netbeans
  • Apache Commands

Copyright 2021 Daniel Bower
  • My Lab
  • Family
  • Friends
  • Professional
  • About