Link to home
Start Free TrialLog in
Avatar of mtadj
mtadj

asked on

Connecting jconsole to Tomcat on Windows

I am trying to get jconsole to run on my Tomcat 5.5 installation.

I can run jconsole on a sample app that I run from the command line. For example:
$ javac com/example/mbeans/*.java
$ java -Dcom.sun.management.jmxremote com.example.mbeans.Main
$ jconsole

The above works and will find my app.

However for Tomcat I am trying to run jconsole by specifying the PID.  So for example if the pid for Tomcat is 4800:
$ jconsole 4800

I get the following error message:
Unable to attach to 4800: Could not map vmid to user name

Now I am logged in as Administrator.  When I check the task manager, the username for Tomcat is SYSTEM.  The problem is probably here, but I don't know how to resolve it.

And to be thorough in this post, I did set in my CATALINA_OPTS environment variable this line as perscribed and the box has been restarted:
-Dcom.sun.management.jmxremote

Thanks!
Avatar of aozarov
aozarov

1. did you get your tomcat pid by doing: jps
2. Are you running tomcat with java 1.5
Avatar of mtadj

ASKER

In the above example I got the pid from the Windows Task Manager.  Running:
$ jps
gave me a different pid not listed in the task manager.  4748.

However running:
$ jconsole 4748
gave me the same error msg as before.

Yes, we are running java 1.5

Thanks
Read: http://java.sun.com/performance/jvmstat/faq.html (last section)
15. I'm getting the error "Could not attach to vmid : Could not map vmid to user Name"?
This error message occurs when an application makes a native call to setuid() to change the user id associated with the process. Applications often do this because they need to start as root in order to bind to a TCP/IP port below 1024 but then change to a non-privileged user id through this native call. One workaround to this problem is to configure the application to not use a privileged port and to disable its setuid call. Otherwise the jvmstat tools must be run with the same user credentials as the non-privileged application user.

If that is your problem then maybe you want to consider using mod_jk apache to tomcat bridge (so you can bind tomcat to port 8080 without the need for root permissions).
Avatar of mtadj

ASKER

Yeah, I had seen that.  I wasn't sure it applied to our situation, but perhaps it does.

We haven't needed mod_jk for anything so far, so the optimal solution would be to have it working with our current configuration.  But I'll take a look at mod_jk in the mean time.

I don't think we have a special setup really, I was hoping there would be some answer to get jconsole to work with tomcat out-of-the-box.

Thanks
You can run Tomcat as root (though many people don't like it) and in such case there is no need to apply the call to setuid.
Avatar of mtadj

ASKER

Okay, still not working, but here's an update and a checklist of what we've done.

 * We are running Tomcat as Administrator now (not root, this is a Windows Server 2003 box) and we are logging in as Administrator
 ** Tomcat's version is 5.5
 ** Tomcat is running as a Service in windows
 ** When I view the Tomcat tasks in Windows Task Manager it says was logged on with Administrator

 * For the CATALINA_OPTS=-Dcom.sun.management.jmxremote environment variable we set this by going to ControlPanel->System->AdvancedTab->EnvironmentVariables and created an entry under System Variables
 ** Even though Tomcat is running as a service, this is still the correct place to set the environment variable, right?

 * For the pid I am a bit confused on which it should be.  All of the following have different pids.
 ** $ jps
 ** Taskmanager has pids for javaw, tomcat5, and tomcat5w
 ** I've tried them all of course
 ** The command to try them is $ jconsole pid
 ** The error message is alwasy the same: Unable to attach to [port number]: Could not map vmid to user name
 
 * If the pid that jconsole needs to connect to is a java one and not a tomcat one, then in this case the user is still SYSTEM.  How would we change this to Administrator, and which pid should it be?  The one from $ pds or the one for javaw in the Task Manager?

Sorry if that's a lot of information, but hopefully it is enough to solve the problem.

Thanks!
>> this is still the correct place to set the environment variable, right?
For global settings, yes.

For each pid you tried try to run jconsole with that pid user (either login using that user or use the Windows RUNAS command)
Avatar of mtadj

ASKER

I think the above suggestions were good but they never solved our problem.  We are not going to pursue this one any further.  Thanks for your help.
ASKER CERTIFIED SOLUTION
Avatar of Netminder
Netminder

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Well i'm not satisfied with the solution , i ran out in the same problem with Windows 2003 (same configuration) and i dont have solution :)