aspose file tools*
The moose likes Tomcat and the fly likes using VisualVM with Tomcat on another machine Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "using VisualVM with Tomcat on another machine" Watch "using VisualVM with Tomcat on another machine" New topic
Author

using VisualVM with Tomcat on another machine

Anthony Baldarelli
Greenhorn

Joined: Feb 18, 2006
Posts: 22
Hello,
For some reason I cannot access my tomcat web application for profiler analysis either jconsole or visualVM on my Windows Vista machine, but I can directly on the Linux machine where the tomcat is actually running. As per some directions, I openned the port in iptables. Is there any way to see what is stopping it? Is there anyway it could be some messed up Tomcat setting? This would be weird as it works on the localhost machine, but I suppose it is possible, thus the question. Yes, I know this is on the fence as a tomcat topic. I am just starting here, and will move to other groups once I determine my problem is not Tomcat related. Thanks.

TB
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41885
    
  63
It may be necessary to start the Tomcat with the property "-Djava.rmi.server.hostname=127.0.0.1" where the IP address is the one of the machine running Tomcat.


Ping & DNS - my free Android networking tools app
Anthony Baldarelli
Greenhorn

Joined: Feb 18, 2006
Posts: 22
Thanks. I added the IP, as you suggested, and it still does not work from other machines. Maybe I added the wrong IP? I added the IP as seen from other machines, but you have the localhost IP below, in your example. By what you said, I thought you meant the IP as seen from other machines, but did I interpret your words incorrectly?

Here are the current JVM options for tomcat:


In visualVM directly on Linux host, I have the following "Overview" information:

PID: 21530
Host: localhost
Main class: <unknown>
Arguments: <none>

JVM: Java HotSpot(TM) Client VM (20.8-b03, mixed mode, sharing)
Java: version 1.6.0_33, vendor Sun Microsystems Inc.
Java Home: /other/java/jdk1.6.0_33/jre
JVM Flags: <none>

Heap dump on OOME: disabled


Would any other information be helpful? Thanks.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41885
    
  63
No, the IP as seen by other machines is correct. VisualVM must be able to contact the Tomcat machine under that IP address.

What, exactly, does "does not work" mean? Have you tried it without any authentication, just to make sure that works?
Anthony Baldarelli
Greenhorn

Joined: Feb 18, 2006
Posts: 22
Says that it cannot connect, and does not really say why. See attached screenshots.

The current setup in server.xml is below


I have NOT tried it without authentication. I might as well reduce it down to the simplest possible configuration. I got my configuration from various different pages. Let me set it up with the above XML, and the following JMX related command line options only:

I will get back to you with the results.



[Thumbnail for VisualVM-AddJMX.jpg]


[Thumbnail for VisualVM-AddJMX-error.jpg]

Anthony Baldarelli
Greenhorn

Joined: Feb 18, 2006
Posts: 22
Ok, removing authentication did not help. I am going to remove configuration from server.xml and restart tomcat to see if that works. Note that it works from the local machine, just not the remote machine.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41885
    
  63
I just verified that I never touched any of the <Listener> elements. Here are the settings we use on a production system:

JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=$JMXPORT -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.password.file=$BASEPATH/conf/jmxremote.password -Dcom.sun.management.jmxremote.access.file=$BASEPATH/conf/jmxremote.access"

Apparently I only needed the java.rmi.server property when I was monitoring on my home machine.

Is port 10001 open and accessible for your machine, i.e., can you make a socket connection?
Anthony Baldarelli
Greenhorn

Joined: Feb 18, 2006
Posts: 22
First of all, thanks so much for your time and effort. Thanks especially for your production examples. Since you got it to work in such a situation, I at least know it is possible.

So for the "Listener" section, you left it as the default, which I believe looks like the below:



What do you mean by
Apparently I only needed the java.rmi.server property when I was monitoring on my home machine.
. In other words, where are you setting this "java.rmi.server" property you are talking about?


Ok, according to nmap ( running on my Windows Vista machine, but checking my Linux development machine ), the current port I am using ( 8086 ) is open, as per one of my later posts. 10001 is not open, but I am not running tomcat with it right now, so that is probably why.

nmap output:


Also, netstat on the linux machine strong suggests it is open:


Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41885
    
  63
Anthony Baldarelli wrote:In other words, where are you setting this "java.rmi.server" property you are talking about?

In the catalina.sh script that starts the Tomcat, but only if the Tomcat and VisualVM run on the same machine. If they run on different machines, I didn't need to do that. But it can't hurt, and can possibly help.
Anthony Baldarelli
Greenhorn

Joined: Feb 18, 2006
Posts: 22
Thanks, and sorry for a slightly stupid question ( or I feel it is stupid ), but what do you mean? If you do a google search for "java.rmi.server", you see lots of potential properties ( java.rmi.server properties ). Which RMI properties did you set?

Also, I read a separate article that suggested that visualVM uses other ports besides the port we specify. This article ( A Tomcat JVM tutorial ) said they fixed it by opening all ports from a specific IP. Per chance did you guys do something that drastic? Or maybe you firewall is open to everything already?


Total side note: Earlier you asked if I could open a socket connection. I just wanted to confirm that I just ran the command "telnet 192.168.254.162 <PORT>", and it behaved the same way as "telnet 192.168.254.162 80", so I think the port I am using is open and accepts socket connections. I keep changing the port, just to experiment, which is why I describe it as "<PORT>" above. If you have a better way to test it besides telnet and nmap from a separate machine, tell me.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41885
    
  63
Sorry for being misleading; I'm talking about the property called "java.rmi.server.hostname" that I mentioned in my first post.

I'm not sure if other ports are needed; I've only ever used JMX in an internal network or over a VPN, where no firewall existed in between. https://blogs.oracle.com/jmxetc/entry/connecting_through_firewall_using_jmx suggests you need to do some more work, though.
Anthony Baldarelli
Greenhorn

Joined: Feb 18, 2006
Posts: 22
Ok, I am getting somewhere. There was one note at http://javadevsoup.blogspot.com/2012/02/remote-java-profiling-using-visual-vm.html telling me that you had to run visualVM with the same JDK as the application you are profiling. So I found and ran the visualVM application for JDK 1.6.0_13. This is no the exact same version, but it is an earlier version. Now I am downloading the exact same JDK I am using on the production machine to see if I can get that visualVM to work perfectly, like the visualVM on the linux machine works. We shall see.
Anthony Baldarelli
Greenhorn

Joined: Feb 18, 2006
Posts: 22
Ok, now I have installed the exact same JDK and it works a little better. Now my problem is that the memory sampler ( under the "Sampler" tab ) and "Visual GC" tab. When I had this problem on the localhost machine, it was because I was running visualvm under a different user than tomcat was running on.

One easy question to you: You said you could monitor a production system from a remote computer. Per chance can you get data via the "Visual GC" tab and with the "Memory" button in the "Sampler" tab?

Since this probably does not make much since, please see below attachments. It will make sense when you see the attachments for the "Sampler" tab. You will just have to trust me that the two visualVM sessions are for the same JDK version. Note that I give you these screen shots so you know what I am talking about and can answer my "yes/no" question above. I just want to know if it works for you.




[Thumbnail for VirtualVMSampler Vista.jpg]

Anthony Baldarelli
Greenhorn

Joined: Feb 18, 2006
Posts: 22
Well, it would not add the prior screen shot, so here it is again.

I am also including the "Visual GC" screen shots, for completeness.

Thanks again for all your help.



[Thumbnail for VirtualVMSampler Linux.jpg]


[Thumbnail for VirtualVM VisualGC Vista.jpg]


[Thumbnail for VirtualVM VisualGC Linux.jpg]

Anthony Baldarelli
Greenhorn

Joined: Feb 18, 2006
Posts: 22
Ok, I did want to update anyone who is interested. I still have not solved the above issue and would love to see the answer to my question to Ulf Dittmer, BUT, that said, I found javamelody ( https://code.google.com/p/javamelody/ ) and PSI Probe ( https://code.google.com/p/psi-probe/ ). Both of those handy tools give me similar information, and so far seem to work reasonably well. It might not be as good as visualvm, but it is a workable alternative ( for now ). So if you have the same problems as I am, maybe try javamelody or PSI Probe.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41885
    
  63
VisualGC does not work for me remotely due to different JVMs being used. I have no way of trying with identical JVMs.

Memory sampling also doesn't work, but then it mentions not working at all for remote connections, no matter what JVM is used.

Javamelody looks interesting, I'll have to check that out.

I like PSI-Probe a lot, and have recently created a version that bundles it with jmx.browser in a single web app. (I've started using custom MBeans for monitoring and affecting web apps, and having JMX functionality and PSI Probe in the same web app makes managing servers easier.)

Another monitoring tool you may find interesting is Jamon.
 
wood burning stoves
 
subject: using VisualVM with Tomcat on another machine