Jolokia Proxy troubles

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

Jolokia Proxy troubles

I am trying to use Jolokia as a proxy, but it appears to not be proxying my requests properly.
 I am issuing post requests to a server with the Jolokia agent running on a container. When I request jvm stats like
    {
       "type":"READ",
       "mbean":"java.lang:type=Memory",
       "target": {
                "url":"service:jmx:rmi:///jndi/rmi://somehostname:jmxport/jmxrmi"
              }
     }

I get back a response, but it appears to be from teh server the jolokia proxy is running on, not the endpoint I am trying to get data from. When I try listing the mbeans, or reading an mbean I can see in jconsole, I get a not found error  of the style:
    "stacktrace":"javax.management.InstanceNotFoundException: some.custom.namespace:id=core
    at   com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:    1095)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBeanInfo(DefaultMBeanServerInterceptor.java:1375)\n\tat

(request was)
  {
   "type":"READ",
   "mbean":"some.custom.namespace:id=core",
   "target": {
                "url":"service:jmx:rmi:///jndi/rmi://somehostname:someport/jmxrmi"
              }
  }

I have tested the target url, and I can connect to the server with jconsole, and view the mbeans I am trying to read. Is there something special I should be doing durring the set-up of jetty/jolokia to ensure that it knows it should be proxying these requests? is there a reason it would ignore the target and just read from the server the proxy is running in ?


Relevant setup here.
        AgentServlet jolokiaServlet = new AgentServlet();
        jolokiaServlet.init();
        ServletHolder jolokiaHolder = new ServletHolder(jolokiaServlet);
        ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.SESSIONS);
        handler.addServlet(jolokiaHolder, "/jolokia/");
roland roland
Reply | Threaded
Open this post in threaded view
|

Re: Jolokia Proxy troubles

You need to enable the proxy if you do it programmatically by setting the servlet init parameter "dispatcherClasses" to the value "org.jolokia.jsr160.Jsr160RequestDispatcher" (see also https://jolokia.org/reference/html/agents.html#war-agent-installation). Otherwise no proxy is enabled and only the local dispatcher is available.
... roland