Friday, January 22, 2010

Remote Profiling of JBoss using VisualVM

I ran into an issue while trying to setup profiling (using VisualVM) of a remote JBoss server instance. It turns out that the default steps I have found on the internet, assume that your target server (Where JBoss is running on) is accessible via the hostname not only by IP address. Well, just in case you live in an environment where you can access your server via IP but not via hostname, this blog post may hopefully save you an hour googling the solution. In order to setup remote profiling I did:

To my run.conf file (JBoss/bin) I added:

JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
JAVA_OPTS="$JAVA_OPTS -Djava.rmi.server.hostname=IP_ADDRESS_OF_MY_JBOSS"

Particularly, the last line was very important. Without it I was able to telnet to port 6789, thinking everything is cool, however I was unable to connect to it via VisualVM. This missing line caused a few frustrations.

Anyway, once these lines were added, you need to configure jstatd. I created a policy file (I called it tools.policy) for the JVM containing:

grant {

Then, I would be able to start up jstatd:

jstatd -p 1099

And finally, I was able to startup JBoss and connect to my server from VisualVM.

Labels: , ,


Blogger Argonist said...

Thank you for blog. I followed your blog, but it dont be working. Maybe have you any idea?

jboss starts up: java -Xms1024m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+UseTLAB -XX:TLABSize=64K -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.rmi.server.hostname= -Djava.rmi.server.useLocalHostname=true -Djava.endorsed.dirs=/home/testjboss/jboss-5.1.0.GA/lib/endorsed -classpath /home/testjboss/jboss-5.1.0.GA/bin/run.jar org.jboss.Main -c stage -b

jstatd is starting also....

I tried to connect to it via VisualVM, but there is a error message from VisualVM:
"Cannot connect to using service:jmx:jmi:///jndi/rmi://"

Logfile from VisualVM:
INFO [null]: Total physical memory 4.137.959.424
Warning: use of system property netbeans.home in has been obsoleted in favor of InstalledFileLocator
INFO []: connect(service:jmx:rmi:///jndi/rmi:// SSL peer shut down incorrectly
Caused: Remote host closed connection during handshake
at sun.rmi.transport.tcp.TCPChannel.createConnection(
Caused: java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is: Remote host closed connection during handshake
at sun.rmi.transport.tcp.TCPChannel.createConnection(



July 14, 2010 at 9:21 AM  
Anonymous Anonymous said...

Argonist ,I have the same problem. have you found what was wrong ???

August 24, 2010 at 1:17 PM  
Anonymous Anonymous said...

Thank you very much. You helped my pain go away :-)

Did you find out why this is necessary - I only have on network interface anyway?


November 4, 2010 at 6:42 AM  
Anonymous Anonymous said...

can i profile my application running on jboss usingf visualvm ???? pleas help

November 12, 2010 at 1:28 AM  
Anonymous Anonymous said...

Thank you Gunnar !!!!!!!!!!!!

March 20, 2012 at 2:22 PM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home