|« define:Splingo||UUIDs have their place in the world »|
JMX examples don't work under windowsNovember 25th, 2008
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
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
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:
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:
Re-ran my mbeans application and all was well.
Thanks for posting that - I’ve put a link to your post here:
I hope it can help other developers!
> tilde “~” is Un*x talk for your home directory.
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:
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.
I understand the DOS abbreviation and that there is a real directory but if your %TMP% folder contains tildes it just doesn’t work!
Thanks for the info. Helped me as well. Before I knew about this TMP environment variable fix only workaround was to tell jmxremote port explicitly in command line and use remote connection facility of jconsole.
* starting of java example app to examine: java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8081 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -jar Notepad.jar
* starting of jconsole: jconsole localhost:8081
But after setting TMP to not tilde path everything worked fine without this remote connection workaround.
I am trying to connect to a remote machne using jconsole through windows command line. But not able to connect, here is the command I am using : jconsole host:38686 -J-usernema=admin -J-password=admin