4

I'm trying to set up JVisualVm to monitor a Tomcat 6 instance (running on Ubuntu Server 10.04 LTS). I've seen other questions, but none of them directly answer my problem. I try to connect to Tomcat with JVisualvm and it comes back with a "Cannot connect" error - but there are TCP connections being made to the server; the server drops the connection after a short burst of traffic.

I have already added this to /etc/default/tomcat6 and restarted tomcat6

# This enables JMX in order to permit VisualVM to profile the JVM.
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=9090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"

I started rmiregistry using default settings:

rmiregistry &

I haven't started jstatd; installing it on the server requires the full JDK which requires X libraries. I'm not about to install X just to get one single binary.

I wonder if not running jstatd would have something to do with it; I was of the impression that I needed neither RMI nor jstatd, as long as I could use JMX directly via the JMX port.

There is no firewall in between the server and the JVisualvm client, and the iptables host firewall is open. Using jconsole results in the same error.

Running JVisualVM against the local Ubuntu 10.04 machine (by using its IP address and JMX port) and adding a JMX instance works fine - and I'm running neither rmiregistry nor jstatd - though the monitor shows RMI threads running.

Question: What must I do (either on the server or the client) in order to be able to monitor Tomcat (and other Java programs) via JMX with JVisualVM?

Thanks in advance.

Mei
  • 1,129
  • 1
  • 11
  • 20
  • If jconsole is failing, that's what I'd lead with - it's more basic than VVM - jconsole ships with the JDK, right?, so the answers you get are more likely to be on point. – Ladlestein Jun 14 '11 at 17:54
  • No: the error message was exactly the same. I understand, too, that jconsole has reached end-of-life as well. – Mei Jun 14 '11 at 19:42
  • @Ladlestein VisualVM also ships with JDK. – Tomas Hurka Jun 15 '11 at 07:51
  • True. However, the JDK and VisualVM are separate in the Ubuntu repositories. – Mei Jun 15 '11 at 14:45

2 Answers2

4

If there is no firewall, try to set java.rmi.server.hostname system property for your Tomcat. Add this to your Tomcat's JAVA_OPTS:

-Djava.rmi.server.hostname=<IP address of Ubuntu Server>

You don't need to start rmiregistry and you don't need to run jstatd to be able to monitor your Tomcat remotely.

Tomas Hurka
  • 6,723
  • 29
  • 38
  • That's what I did finally: worked like charm! However, I did have to start rmiregistry... Did I miss something? – Mei Jun 15 '11 at 14:36
  • I don't know why you need rmiregistry. Normally JMX connection works fine without explicitly started rmiregistry. Which connection string are you using to connect to your remote Tomcat? – Tomas Hurka Jun 16 '11 at 20:27
  • I'm just specifying a JMX connection: `host:port` - that's all. I'll probably try working it again without the rmiregistry running. – Mei Jun 16 '11 at 22:52
0

For the record: jstatd does not require X libraries, it only depends on them via some other recommended package. You can make aptitude or apt-get skip installation of recommended packages and have jstatd installed without any X11 libraries.

For aptitude, go into options ➞ preferences ➞ Install recommended packages automatically. For apt-get, see this question on askubuntu.

Community
  • 1
  • 1
Ronald Paul
  • 421
  • 2
  • 5