Note that there are some explanatory texts on larger screens.

plurals
  1. POTomcat JMX connection - Authentication failed
    text
    copied!<p>I am having some problems setting up Tomcat for JMX. I added the following properties to</p> <pre><code> CATALINA_OPTS="-Dcom.sun.management.jmxremote.port=18070 -Dcom.sun.management.jmxremote.password.file=$CATALINA_BASE/conf/jmxremote.password -Dcom.sun .management.jmxremote.ssl=false" </code></pre> <p>And have added the jmxremote.password file in to the conf directory. I wrote a client tool that connects to the JMX server running on port 18070. When i run the client program i get the following error. </p> <pre><code> Exception in thread "main" java.lang.SecurityException: Authentication failed! Credentials required at com.sun.jmx.remote.security.JMXPluggableAuthenticator.authenticationFailure(JMXPluggableAuthenticator.java:193) at com.sun.jmx.remote.security.JMXPluggableAuthenticator.authenticate(JMXPluggableAuthenticator.java:145) at sun.management.jmxremote.ConnectorBootstrap$AccessFileCheckerAuthenticator.authenticate(ConnectorBootstrap.java:185) at javax.management.remote.rmi.RMIServerImpl.doNewClient(RMIServerImpl.java:213) at javax.management.remote.rmi.RMIServerImpl.newClient(RMIServerImpl.java:180) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305) at sun.rmi.transport.Transport$1.run(Transport.java:159) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:155) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) at java.lang.Thread.run(Thread.java:619) at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255) at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233) at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142) at javax.management.remote.rmi.RMIServerImpl_Stub.newClient(Unknown Source) at javax.management.remote.rmi.RMIConnector.getConnection(RMIConnector.java:2312) at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:277) at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248) at com.bt.c21sc.c21tkprobe.accessors.C21TkProbeJmxDAO.connect(Unknown Source) at com.bt.c21sc.c21tkprobe.service.C21TkProbeBD.execute(Unknown Source) at com.bt.c21sc.c21tkprobe.C21AppserverProbe.main(Unknown Source) </code></pre> <p>If i change the CATALINA_OPTS properties to </p> <pre><code>CATALINA_OPTS="-Dcom.sun.management.jmxremote.port=18070 -Dcom.sun.management.jmxremote.password.file=$CATALINA_BASE/conf/jmxremote.password -Dcom.sun .management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false" </code></pre> <p>Then it works fine. I think what i am confused of is what is classed as remote access. I am running the client program away from the Tomcat instance but both Tomcat and the client tool are on the same machine (i.e. different virtual machines but same environemnt). I thought i had to configure the remote authentication if i access the JMX server remotely from a different machine. </p> <p>By remote access do they mean accessing the JMX server from any VM either locally or remotely? </p> <h2>Edit</h2> <p>Thanks. I found out that the problem was that even though i was supplying the username and password in the jmxremort.password and jmxremote.access files i still had to supply the username and password from the client. </p> <p>You are right that i dont have to supply the user credentials if run locally. I have proved this as i can access the Tomcat's JVM via Jconsole. </p> <p>I am accessing it programmatically so i have to supply a URL which is shown below service:jmx:rmi:///jndi/rmi://localhost:9004/jmxrmi</p> <p>I then get the jmx server as shown below. </p> <pre><code>url = new JMXServiceURL(urlString); Hashtable&lt;String, String[]&gt; env = new Hashtable&lt;String, String[]&gt;(); String[] credentials = new String[] {user,pass}; env.put(JMXConnector.CREDENTIALS, credentials); jmxc = JMXConnectorFactory.connect(url,env); mbsc = jmxc.getMBeanServerConnection(); </code></pre> <p>If i am accessing this locally how would i go about this? I know that it dont work locally without the user credentials as that is how i found out that i need to provide. if Jconsole or visualvm can connect to it then there must be a different approach that allows retrieving the Tomcat jmx server without having to supply the port number. </p> <p>The URL includes a port number. If im accessing the JMX server programmatically, how would i access it without having to specify the port number?</p> <p>By the way i am using Tomcat 5.5 and JDK 1.6</p> <p>Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload