Skip to content


Monitoring Remote Java Apps

Monitoring remote Java applications may not be a very easy task. Especially considering the application needed to be started with -Dcom.sun.management.jmxremote option to allow jConsole access it.

VisualVM has made it a bit easier for us to monitor remote apps. You will have to start jstatd process on your remote system and then you can monitor how your remote VM is feeling.

However.. there are some pitfalls. Here are 2 of the most annoying once:

When starting jstatd you are getting Security Exceptions

To solve this error you will need to create a policy file containing something like this (call it jstatd.all.policy):

grant codebase "file:${java.home}/../lib/tools.jar" {

permission java.security.AllPermission;

};

Now start jstatd with the following command:

jstatd -J-Djava.security.policy=jstatd.all.policy

You are trying to connect to the remote host but getting Socket connection refused.

This is most likely caused because of an underlying exception – connection refused to host 127.0.0.1 or something simmilar (not the IP you are trying to access). This is easily solved by adding the following parameter to jstatd startup command:

-J-Djava.rmi.server.hostname=<your ip or hostname>

… Naturally there are more pitfalls but I am not going to cover all of them here. VirtualVM, just like legacy jConsole may be very usefull for monitoring how some applications act in the testing environment before you put them into producstion. Usually things that do not appear on your development machine while profiling may appear in the test environment where it is hard to notice them without profiling.

One of such problems may be MySQL Connector/J PermGen leak caused by Statement cancelation timer (something i have encountered recently and trying to come around)

Posted in Java, Programming. Tagged with , , .

0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.