java.lang.ClassCastException: org.jolokia.detector.ActiveMQDetector cannot be cast to org.jolokia.detector.ServerDetector

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

java.lang.ClassCastException: org.jolokia.detector.ActiveMQDetector cannot be cast to org.jolokia.detector.ServerDetector

Jose Manuel Vega Monroy

Hi there,

 

Trying to configure Hawtio in ActiveMq broker 5.15.0 in order to use jolokia to get metrics via HTTP, getting this exception:

 

2019-10-13 21:18:59,271 [main] WARN (ContextHandler.java:2062) - unavailable java.lang.ClassCastException: org.jolokia.detector.ActiveMQDetector cannot be cast to org.jolokia.detector.ServerDetector at org.jolokia.backend.MBeanServers.<init>(MBeanServers.java:51) at org.jolokia.backend.MBeanServerExecutorLocal.init(MBeanServerExecutorLocal.java:84) at org.jolokia.backend.MBeanServerExecutorLocal.<init>(MBeanServerExecutorLocal.java:55) at org.jolokia.backend.MBeanServerHandler.<init>(MBeanServerHandler.java:69) at org.jolokia.backend.LocalRequestDispatcher.<init>(LocalRequestDispatcher.java:71) at org.jolokia.backend.BackendManager.init(BackendManager.java:327) at org.jolokia.backend.BackendManager.<init>(BackendManager.java:130) at org.jolokia.backend.BackendManager.<init>(BackendManager.java:105) at org.jolokia.http.AgentServlet.init(AgentServlet.java:159) at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:616) at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:396) at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:871) at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:298) at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1349) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1342) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:505) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) at org.eclipse.jetty.security.SecurityHandler.doStart(SecurityHandler.java:391) at org.eclipse.jetty.security.ConstraintSecurityHandler.doStart(ConstraintSecurityHandler.java:449) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132) at org.eclipse.jetty.server.Server.start(Server.java:387) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114) at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61) at org.eclipse.jetty.server.Server.doStart(Server.java:354) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:269) at org.springframework.beans.factory.config.MethodInvokingBean.invokeWithTargetException(MethodInvokingBean.java:119) at org.springframework.beans.factory.config.MethodInvokingFactoryBean.afterPropertiesSet(MethodInvokingFactoryBean.java:106) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:742) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) at org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(ResourceXmlApplicationContext.java:64) at org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(ResourceXmlApplicationContext.java:52) at org.apache.activemq.xbean.XBeanBrokerFactory$1.<init>(XBeanBrokerFactory.java:104) at org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext(XBeanBrokerFactory.java:104) at org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBrokerFactory.java:67) at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:71) at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:54) at org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:87) at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:63) at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:154) at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:63) at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:104) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.activemq.console.Main.runTaskClass(Main.java:262) at org.apache.activemq.console.Main.main(Main.java:115)

 

And when requesting, response is the next:

 

curl -u admin:admin http://localhost:8161/hawtio/jolokia -v

* About to connect() to localhost port 8161 (#0)

*   Trying 127.0.0.1... connected

* Connected to localhost (127.0.0.1) port 8161 (#0)

* Server auth using Basic with user 'admin'

> GET /hawtio/jolokia HTTP/1.1

> Authorization: Basic YWRtaW46YWRtaW4=

> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.36 zlib/1.2.3 libidn/1.18 libssh2/1.4.2

> Host: localhost:8161

> Accept: */*

> 

< HTTP/1.1 503 Service Unavailable

< Date: Sun, 13 Oct 2019 20:19:22 GMT

< X-FRAME-OPTIONS: SAMEORIGIN

< Cache-Control: must-revalidate,no-cache,no-store

< Content-Type: text/html; charset=ISO-8859-1

< Content-Length: 302

< Server: Jetty(9.2.22.v20170606)

< 

<html>

<head>

<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>

<title>Error 503 </title>

</head>

<body>

<h2>HTTP ERROR: 503</h2>

<p>Problem accessing /hawtio/jolokia. Reason:

<pre>    Service Unavailable</pre></p>

<hr /><i><small>Powered by Jetty://</small></i>

</body>

</html>

* Connection #0 to host localhost left intact

* Closing connection #0

 

Any idea? I tried different versions of Hawtio (1.1, 1.3.1 and 2.3.0), but getting the same.

 

Thanks

 

Jose Manuel Vega Monroy 
Java Developer / Software Developer Engineer in Test

Direct: +0035 0 2008038 (Ext. 8038)
Email: 
[hidden email]

William Hill | 6/1 Waterport Place | Gibraltar | GX11 1AA

 

 

 

Reply | Threaded
Open this post in threaded view
|

Re: java.lang.ClassCastException: org.jolokia.detector.ActiveMQDetector cannot be cast to org.jolokia.detector.ServerDetector

Tim Bain
The fact that you're getting a ClassCastException for something that's
clearly in the class hierarchy makes me think that you've got two different
JARs with these Jolokia classes on your classpath, where ActiveMQDetector
is getting loaded from one JAR and ServerDetector is getting loaded from a
different one. When that happens, ActiveMQDetector says that the version of
ServerDetector from the other JAR isn't in its class/interface hierarchy,
which seems likely to be what's going on with the stack trace above. So I'd
recommend you look at what JARs are getting loaded on your classpath and
whether more than one of them contains these classes.

Tim

On Sun, Oct 13, 2019 at 2:26 PM Jose Manuel Vega Monroy <
[hidden email]> wrote:

> Hi there,
>
>
>
> Trying to *configure Hawtio in ActiveMq broker 5.15.0 in order to use
> jolokia to get metrics via HTTP*, getting this exception:
>
>
>
> 2019-10-13 21:18:59,271 [main] WARN (ContextHandler.java:2062) -
> unavailable java.lang.ClassCastException: org.jolokia.detector.ActiveMQDetector
> cannot be cast to org.jolokia.detector.ServerDetector at org.jolokia.backend.MBeanServers.<init>(MBeanServers.java:51)
> at org.jolokia.backend.MBeanServerExecutorLocal.init(MBeanServerExecutorLocal.java:84)
> at org.jolokia.backend.MBeanServerExecutorLocal.<init>(MBeanServerExecutorLocal.java:55)
> at org.jolokia.backend.MBeanServerHandler.<init>(MBeanServerHandler.java:69)
> at org.jolokia.backend.LocalRequestDispatcher.<init>(LocalRequestDispatcher.java:71)
> at org.jolokia.backend.BackendManager.init(BackendManager.java:327) at
> org.jolokia.backend.BackendManager.<init>(BackendManager.java:130) at org.
> jolokia.backend.BackendManager.<init>(BackendManager.java:105) at org.
> jolokia.http.AgentServlet.init(AgentServlet.java:159) at
> org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:616)
> at
> org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:396)
> at
> org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:871)
> at
> org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:298)
> at
> org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1349)
> at
> org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1342)
> at
> org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)
> at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:505)
> at
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
> at
> org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
> at
> org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
> at
> org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
> at
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
> at
> org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
> at
> org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
> at
> org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
> at
> org.eclipse.jetty.security.SecurityHandler.doStart(SecurityHandler.java:391)
> at
> org.eclipse.jetty.security.ConstraintSecurityHandler.doStart(ConstraintSecurityHandler.java:449)
> at
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
> at
> org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
> at
> org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
> at
> org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
> at
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
> at
> org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
> at org.eclipse.jetty.server.Server.start(Server.java:387) at
> org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
> at
> org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
> at org.eclipse.jetty.server.Server.doStart(Server.java:354) at
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498) at
> org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:269) at
> org.springframework.beans.factory.config.MethodInvokingBean.invokeWithTargetException(MethodInvokingBean.java:119)
> at
> org.springframework.beans.factory.config.MethodInvokingFactoryBean.afterPropertiesSet(MethodInvokingFactoryBean.java:106)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
> at
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
> at
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
> at
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
> at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
> at
> org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:742)
> at
> org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
> at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
> at
> org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(ResourceXmlApplicationContext.java:64)
> at
> org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(ResourceXmlApplicationContext.java:52)
> at
> org.apache.activemq.xbean.XBeanBrokerFactory$1.<init>(XBeanBrokerFactory.java:104)
> at
> org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext(XBeanBrokerFactory.java:104)
> at
> org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBrokerFactory.java:67)
> at
> org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:71)
> at
> org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:54)
> at
> org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:87)
> at
> org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:63)
> at
> org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:154)
> at
> org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:63)
> at
> org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:104)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498) at
> org.apache.activemq.console.Main.runTaskClass(Main.java:262) at
> org.apache.activemq.console.Main.main(Main.java:115)
>
>
>
> And when requesting, response is the next:
>
>
>
> curl -u admin:admin http://localhost:8161/hawtio/jolokia -v
>
> * About to connect() to localhost port 8161 (#0)
>
> *   Trying 127.0.0.1... connected
>
> * Connected to localhost (127.0.0.1) port 8161 (#0)
>
> * Server auth using Basic with user 'admin'
>
> > GET /hawtio/jolokia HTTP/1.1
>
> > Authorization: Basic YWRtaW46YWRtaW4=
>
> > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7
> NSS/3.36 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
>
> > Host: localhost:8161
>
> > Accept: */*
>
> >
>
> < HTTP/1.1 503 Service Unavailable
>
> < Date: Sun, 13 Oct 2019 20:19:22 GMT
>
> < X-FRAME-OPTIONS: SAMEORIGIN
>
> < Cache-Control: must-revalidate,no-cache,no-store
>
> < Content-Type: text/html; charset=ISO-8859-1
>
> < Content-Length: 302
>
> < Server: Jetty(9.2.22.v20170606)
>
> <
>
> <html>
>
> <head>
>
> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
>
> <title>Error 503 </title>
>
> </head>
>
> <body>
>
> <h2>HTTP ERROR: 503</h2>
>
> <p>Problem accessing /hawtio/jolokia. Reason:
>
> <pre>    Service Unavailable</pre></p>
>
> <hr /><i><small>Powered by Jetty://</small></i>
>
> </body>
>
> </html>
>
> * Connection #0 to host localhost left intact
>
> * Closing connection #0
>
>
>
> Any idea? I tried different versions of Hawtio (1.1, 1.3.1 and 2.3.0), but
> getting the same.
>
>
>
> Thanks
>
>
>
> [image:
> https://www.williamhillplc.com/content/signature/WHlogo.gif?width=180]
> <http://www.williamhill.com/>
>
> [image:
> https://www.williamhillplc.com/content/signature/senet.gif?width=180]
> <http://www.whenthefunstops.co.uk/>
>
> *Jose Manuel Vega Monroy *
> *Java Developer / Software Developer Engineer in Test*
>
> Direct: +*0035 0 2008038 (Ext. 8038)*
> Email: [hidden email]
>
> William Hill | 6/1 Waterport Place | Gibraltar | GX11 1AA
>
>
>
>
>
>
>