Wednesday, October 24, 2012

JConsole – not able to connect to java processes on Windows 7 – solution

Today I was trying to connect my java 1.6.0_27 jconsole to an UltraEsb process. I could see local java processes IDs. However there was no process description or path information. Connect button was grayed out for all local java processes except that for “Jconsole” itself.

After wasting 45 minutes trying to restart all processes and making sure that my java versions are in sync between jconsole and all processes to be monitored, fortunately I found this useful blog post which explained that this is due to some file name quirk.  Apparently, all java processes add an entry about themselves in a folder under TEMP folder. This folder is named as hsperfdata_Username.

Now here is the catch. Jconsole wants  Username part of this folder to be exactly same as process owner name shown in windows 7 task manager. In my machine java processes were running as user DGoyal. Name of “hsperfdata*” folder was hsperfdata_dgoyal. I stopped all java processes, kill agent*32.exe process and then renamed  this folder to hsperfdata_DGoyal. I started all processes and JConsole. Now JConsole was able to connect to java processes.

One more note,  on Windows 7 this temp folder is set under your profile. Default is C:\Users\<username>\AppData\Local\Temp. You should set TEMP as well as TMP environment variable to your desired location.

2 comments:

  1. This helped me to find my solution:
    Delete the hsperfdata_xxx folder and restart the java app and jconsole/jvisualvm. And voila.

    ReplyDelete