Configure jvm agent to act as a jolokia proxy

classic Classic list List threaded Threaded
2 messages Options
subburathinamv subburathinamv
Reply | Threaded
Open this post in threaded view

Configure jvm agent to act as a jolokia proxy

Is it possible to configure a agent as a jolokia proxy so that it can talk to other jvms and get the mbean information

For example , I have a tomcat application and I followed the below steps .

Steps :
1. I have configured this application as jolokia agent with the below params
2. Restart tomcat application.

Access : http://localhost:8779/jolokia/ and it worked fine.

3. Can I configure this tomcat application to act as my jolokia proxy as well so that it can query for mbean information from other jvm's as well.

I was thinking that I can change the agent configuration in step 1 to use JSR160 dispatcher


and access the jmx info of another jvm using the below post request

 curl -X POST http://localhost:8779/jolokia/ -d '{"type":"READ", "mbean":"java.lang:type=Threading", "attribute":"ThreadCount","target": { "url":"service:jmx:rmi:///jndi/rmi://localhost:9004/jmxrmi" }}'

There is another java process that has jmx enabled on port 9004 and I am trying to get the thread count.

Response :

curl -X POST http://localhost:8779/jolokia/ -d '{"type":"READ", "mbean":"java.lang:type=Threading", "attribute":"ThreadCount","target": { "url":"service:jmx:rmi:///jndi/rmi://localhost:9004/jmxrmi" }}'
{"request":{"mbean":"java.lang:type=Threading","attribute":"ThreadCount","type":"read","target":{"url":"service:jmx:rmi:\/\/\/jndi\/rmi:\/\/localhost:9004\/jmxrmi"}},"stacktrace":" Failed to retrieve RMIServer stub: javax.naming.NoInitialContextException: Cannot instantiate class: [Root exception is java.lang.ClassNotFoundException:]\n\tat\n\tat\n\tat org.jolokia.jsr160.Jsr160RequestDispatcher.dispatchRequest(\n\tat org.jolokia.backend.BackendManager.callRequestDispatcher(\n\tat org.jolokia.backend.BackendManager.handleRequest(\n\tat org.jolokia.http.HttpRequestHandler.executeRequest(\n\tat org.jolokia.http.HttpRequestHandler.handlePostRequest(\n\tat org.jolokia.jvmagent.JolokiaHttpHandler.executePostRequest(\n\tat org.jolokia.jvmagent.JolokiaHttpHandler.doHandle(\n\tat org.jolokia.jvmagent.JolokiaHttpHandler.handle(\n\tat$Chain.doFilter(\n\tat\n\tat$Chain.doFilter(\n\tat$Exchange$LinkHandler.handle(\n\tat$Chain.doFilter(\n\tat$\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(\n\tat java.util.concurrent.ThreadPoolExecutor$\n\tat\nCaused by: javax.naming.NoInitialContextException: Cannot instantiate class: [Root exception is java.lang.ClassNotFoundException:]\n\tat javax.naming.spi.NamingManager.getInitialContext(\n\tat javax.naming.InitialContext.getDefaultInitCtx(\n\tat javax.naming.InitialContext.init(\n\tat javax.naming.InitialContext.<init>(\n\tat\n\tat\n\tat\n\t... 18 more\nCaused by: java.lang.ClassNotFoundException:\n\tat\n\tat java.lang.ClassLoader.loadClass(\n\tat sun.misc.Launcher$AppClassLoader.loadClass(\n\tat java.lang.ClassLoader.loadClass(\n\tat java.lang.Class.forName0(Native Method)\n\tat java.lang.Class.forName(\n\tat com.sun.naming.internal.VersionHelper12.loadClass(\n\tat com.sun.naming.internal.VersionHelper12.loadClass(\n\tat javax.naming.spi.NamingManager.getInitialContext(\n\t... 24 more\n","error_type":"","error":" : Failed to retrieve RMIServer stub: javax.naming.NoInitialContextException: Cannot instantiate class: [Root exception is java.lang.ClassNotFoundException:]","status":500}

Any idea if I am missing something ?

If I configure all the java processes with jolokia agents on different port , It will work. I don't want to configure jolokia on all the java processes. I need one of the jolokia jvm agents to act as a proxy and get me the jmx info from the other processes.

roland roland
Reply | Threaded
Open this post in threaded view

Re: Configure jvm agent to act as a jolokia proxy

Can you access the target, JSR-160 exposed, server with a standard JMX tool like jconsole ?  For it feels like the JMX parameters on the servers end is not configured properly.

The stacktrace indicates that Jolokia has problems to create a RMIConnector because of some weird configuration in the Tomcat (" missing")

If you can connect, can you please open an issue at so that we can track down the problem with proxy used by an JVM agent. The normal usage for the proxy is with the WAR Jolokia agent, but it should work with the JVM agent, too.

Could you try to use e.g. a Jetty as proxy ?
... roland