VisualVM and jps Not Finding my Java Process

Today I was hit by a weird problem and I thought I’ll share the problem and the solution (thanks for the solution goes to my colleague Lauri). Googling did not help me much (probably bad keywords or not much information about it) and hopefully this post will serve as future destination for a solution for this problem.

Problem

You are running Mac OS X (maybe the problem is relevant on other platforms too) and even if you’ve started Tomcat and you can see the Java process in the Activity Monitor or with ps you can’t see the process with jps. You are not able to connect to the process with VisualVM nor JConsole. Bummer.

Solution

Tomcat scripts have a variable called CATALINA_TMPDIR and the java process is forked with

-Djava.io.tmpdir="$CATALINA_TMPDIR"

What happens is that jps and VisualVM/JConsole look for information about processes from the system TMP folder. Once you redefine this they cannot find their information. The solution is to eliminate this variable from the process.

Either execute the commandline that you can copy and paste from

ps aux | grep -i tomcat

and exclude the -Djava.io.tmpdir part or modify the script for your debug session. Thats it.

You’re welcome.

  • Tomas Hurka

    VisualVM/jps problem is caused by a bug in JDK. See http://bit.ly/iaQmYP. The fix of this regression is available in JDK 6 update 25

  • http://twitter.com/toomasr Toomas Römer

    Oh, thanks for the information, this explains why I did not have to jump through so many hoops previously.

  • Anonymous

    Thanks for sharing! http://www.kevils.com/

  • Albert

    On Mac, you can fix this by setting:

    export CATALINA_TMPDIR=$TMPDIR
     

  • http://www.jps.im/ villa holidays javea

    The town is mainly divided into three sections, Old Town, Port and Arenal. The Old Town is the older section of the town, which is situated a little away from the coast, as inhabitants lived in constant fear of attacks by pirates. The main waterfront has the port of Aduanas de Mar along with the marina. The coastline itself is marked with several restaurants, bars and cafés. The Arenal beach here is the main attraction and is abuzz with many activities all year long.