views:

2879

answers:

8

I am trying to connect to a remote tomcat JMX instance using jConsole. But can't connect successfully. Any Idea?

I included the following option in remote tomcat catalina.sh:

JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote \
    -Dcom.sun.management.jmxremote.port=9004 \
    -Dcom.sun.management.jmxremote.ssl=false \
    -Dcom.sun.management.jmxremote.authenticate=false"
A: 

The parameter looks correct. I assume you specified correct host and port in jconsole. Next, I would check connectivity issues like firewall.

ZZ Coder
i disabled firewall in both ends
Niger
A: 

Was Tomcat restarted after the change?

Are you sure that something else in the startup script isn't overwriting JAVA_OPTS?

matt b
yes I checked catalina.sh, im not overwritting anywhere
Niger
+1  A: 

What exactly do you mean when you say "But can't connect successfully."? Is there an error message? Try turning on logging in jconsole and see if that helps debug it.

To turn on jconsole logging, edit a file named logging.properties in the directory you will be running jconsole in, add:

handlers= java.util.logging.ConsoleHandler

.level=INFO

java.util.logging.FileHandler.pattern = %h/java%u.log
java.util.logging.FileHandler.limit = 50000
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter

java.util.logging.ConsoleHandler.level = FINEST
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

javax.management.level=FINEST
javax.management.remote.level=FINEST

Then, start jconsole with:

jconsole -J-Djava.util.logging.config.file=logging.properties
joe p
Joe, i am getting the following exception. Ignoring logging error suggest whats the issue at com.sun.jmx.remote.util.ClassLogger.finer(ClassLogger.java:130) at com.sun.jmx.remote.util.ClassLogger.trace(ClassLogger.java:88) at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:245) at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:227) at sun.tools.jconsole.ProxyClient.tryConnect(ProxyClient.java:334) at sun.tools.jconsole.ProxyClient.connect(ProxyClient.java:296) at sun.tools.jconsole.VMPanel$2.run(VMPanel.java:280)
Niger
Sorry, I had a typo in the logging.properties text. I edited my post, try making that file again and see if you can get some debugging info.
joe p
+7  A: 

I had a similar, if not the same, problem. I could connect to the JMX server if I started jconsole locally on the machine.

It appears the RMI server was not listening on the correct ip. So, as was suggested in this related question, I added the following:

-Djava.rmi.server.hostname=<host ip>

to JAVA_OPTS as well, and then it worked.

waxwing
Thanks very much. That's what I needed.
Conor
Worked for me I just set the host ip to 127.0.0.1 and it worked for me on my local machine.
rado
Do we add this to the server's JAVA_OPTS or local machine JAVA_OPTS ?
jpartogi
The server's JAVA_OPTS.
waxwing
A: 

We have a similar problem right now. The port is open on the firewall, and connecting locally via the command line seems OK. But when we try to connect remotely, we get a connection refused after a 3-minute timeout. And it says the connection was refused from the internal IP address of the box, 10.x.y.z.

(I know this is not an answer, but the same question as the original -- sorry ;))

Yoav Shapira
A: 

The Jconsole from JDK1.6 or JDK1.7 is more informative. It would probably help you figure this out a little. Every little bit helps. Just download a newer jdk, put it in a Temp directory and run the bin/jconsole from there.

djangofan
A: 

what string are you using as the JMX connection url. I don't mean to point out the obvious but JConsole has a terrible interface and to me requires an overly complex url before it will connect to a remote jmx app. Mine looks like this:

service:jmx:rmi:///jndi/rmi://(hostname):(jmxport)/jmxrmi

Matt
A: 

Did you guys tried changing the remote port ? Sometimes that port is used by some other process on the machine.

vsingh