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.