Can't stop tomcat normally when I configure jmxremote
Asked Answered
O

3

6

I added a jmxremote configuraiton in the catalina.bat:

set JAVA_OPTS=-Dcom.sun.management.jmxremote.port=9004 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false

so that I could start jconsole to monitor the tomcat's performance.

But I got a problem that I couldn't stop tomcat normally through $CATALINA_HOME\catalina.bat stop, neither did $CATALINA_HOME\shutdown.bat

Any suggestions?

Offoffbroadway answered 20/11, 2011 at 5:20 Comment(1)
What do the logs indicate, if anything?Dinerman
U
6

In order to monitor the java process, you need to add the following system properties to the command line:

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9999
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false

In the visualvm you just use the connection string host:9999.

However, sometimes the RMI listener listens to the wrong IP address, one which is inaccessible to the visualvm. Thanks to Pavel’s tip, I found a way to overcome this is by adding the following parameters:

-Djava.rmi.server.hostname=$(hostname)
-Djava.rmi.server.useLocalHostname=true

Now it works like a charm!

For completeness, I’d mention you can secure the connection to the JVM, either by requiring user/password or by using SSL. If you are interested, please see this guide.

Make sure that you put the definitions in a place only the start command sees, but not the shutdown. The reason or this is that the jmx remote create a listening socket, making the shutdown to listen to the same port if not configured properly.

Unearth answered 24/11, 2011 at 9:47 Comment(10)
thanks, I have the same problem as the author. I just added these properties to the JAVA_OPTS variable, which is used on a shutdown too I suppose? So you think it can be the cause of issue?Stepha
@Stepha if the shutdown tries to open a listening socket on an already bound socket, then it will fail. Make sure you don't add the JMX definition to the stop commandUnearth
Thank you, I got it. Put the jmxremote setting in the doStart block and it will be okDeafmute
Also - make sure that the JMX properties are in CATALINA_OPTS, not JAVA_OPTSUnearth
This answer is a perfect example why answers shouldn't consist only of a link - your link is broken.Neocolonialism
Thanks, it's fixed nowUnearth
the blog link is not working.can you add the content in editTelephonic
David was right.Catalina_opts was not used in stop block.so putting it in Catalina_opts solved the problem.Telephonic
The link is dead. Now this post is useless.Commencement
@Commencement I've updated the post with the informationUnearth
W
0

Are you sure Tomcat started successfully?

Usually you need to add this property before the other jmx properties:

-Dcom.sun.management.jmxremote

http://tomcat.apache.org/tomcat-6.0-doc/monitoring.html#Enabling_JMX_Remote

Walworth answered 20/11, 2011 at 5:31 Comment(0)
I
0

Better to add these parameters to the CATALINA_OPTS in the file setenv.sh or setenv.bat

# JMX OPTIONS
CATALINA_OPT="$CATALINA_OPT "-Dcom.sun.management.jmxremote
CATALINA_OPT="$CATALINA_OPT "-Dcom.sun.management.jmxremote.port=9012
CATALINA_OPT="$CATALINA_OPT "-Dcom.sun.management.jmxremote.local.only=false
CATALINA_OPT="$CATALINA_OPT "-Dcom.sun.management.jmxremote.authenticate=false
CATALINA_OPT="$CATALINA_OPT "-Dcom.sun.management.jmxremote.ssl=false
Initiate answered 27/4, 2018 at 14:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.