| « define:Splingo | UUIDs have their place in the world » |
JMX examples don't work under windows
As you know I have been doing a lot of work with Java application containers and the like. I have recently been looking at Java Management Extensions.
What is JMX?
JMX is a technology that lets you implement management interfaces for Java applications.
Copied that line from here, but the idea is that you write a java managed bean (MBeans) and register it with the JMX infrastructure. The JMX technology handles how people get at that information or service. The MBean can do several things like, peek at information, poke new values, initiate calls in the application or do notifications.
There is a handy set of tutorials written by Sun to help you learn. I tried them but unfortunately I couldn’t get it to work.
I compiled the java files exactly the way the instructions described, and when the instructions said launch jconsole and:
Select com.example.mbeans.Main from the list in the “New Connection” window, and click on “Connect".
My window did not have that class listed. Mine had the java process id only. When I used jps (java process list), it said:
668 – process information unavailable
2468 Jps
I eventually had to ask a question in Sun’s JMX forum and was pointed to the troubleshooting connection problems in jconsole, which although was not completely accurate it did point me in the direction of success.
The problem comes from the the TMP environment variable. Under windows my environment variable was set to:
C:\tmp\jmx_examples\Essential>echo %TMP%
C:\DOCUME~1\davidne\LOCALS~1\Temp
I know (cos I’m a Un*x bod) that tilde “~” is Un*x talk for your home directory. I think that my TMP variable’s “~” was being translated to:
C:\DOCUME\Documents and Settings\davidne1\davidne\LOCALS\Documents and Settings\davidne1\Temp
which does not exist! As a result jconsole and my JMX application could not communicate with each other and therefore could not make a connection.
To fix the problem I changed the environment variable TMP to point to a real directory on an (NTFS partition (sorry another caveat)) without any funny characters in it:
set TMP=c:\tmp
Re-ran my mbeans application and all was well.
4 comments
Thanks for posting that - I've put a link to your post here:
http://blogs.sun.com/jmxetc/entry/troubleshooting_connection_problems_in_jconsole
I hope it can help other developers!
Cheers,
-- daniel
Maybe true, but in Windows it simply indicates that some characters in a path had to be truncated because they exceeded the MS-DOS 8.3 character limit for file and directory names. So:
C:\DOCUME~1\davidne\LOCALS~1\Temp
Is actually an abbreviated version of:
C:\Documents and Settings\davidne\Local Settings\Temp
You'll find that this directory does in fact exist.
Hope this helps.