Running Jolokia in Jetty 6

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

Running Jolokia in Jetty 6

Hi,

I've been trying to use Jolokia in Jetty 6 and I'm unable to get it to work.

The problem occurs when it tries to Detect which container its running in and uses reflection to call the getVersion() method on org.mortbay.jetty.Server and gets a NullPointerException.

Do you have a workaround or a fix available ?

Regards

Keith


Exception listec below

javax.servlet.ServletException: java.lang.NullPointerException
        at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:446)
        at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:259)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
        at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:593)
        at org.mortbay.jetty.servlet.Context.startContext(Context.java:139)
        at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1191)
        at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:481)
        at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:434)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
        at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:147)
        at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:120)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
        at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:147)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
        at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:117)
        at org.mortbay.jetty.Server.doStart(Server.java:210)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
        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 org.codehaus.cargo.container.jetty.internal.JettyExecutorThread.run(JettyExecutorThread.java:68)
Caused by: java.lang.NullPointerException
        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 org.jolokia.detector.JettyDetector.getVersion(JettyDetector.java:49)
        at org.jolokia.detector.JettyDetector.detect(JettyDetector.java:37)
        at org.jolokia.backend.MBeanServerHandler.detectServers(MBeanServerHandler.java:280)
        at org.jolokia.backend.MBeanServerHandler.<init>(MBeanServerHandler.java:83)
        at org.jolokia.backend.LocalRequestDispatcher.<init>(LocalRequestDispatcher.java:60)
        at org.jolokia.backend.BackendManager.<init>(BackendManager.java:84)
        at org.jolokia.http.AgentServlet.init(AgentServlet.java:91)
        at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:442)
roland roland
Reply | Threaded
Open this post in threaded view
|

Re: Running Jolokia in Jetty 6

Sorry, I can't reproduce this. I just installed a fresh Jetty 6.1.26 and get the following output when pointing my browser to http://localhost:8080/jolokia

{"timestamp":1295967459,"status":200,"request":{"type":"version"},"value":{"protocol":"4.1","agent":"0.82","info":{"product":"jetty","vendor":"Mortbay","version":"6.1.26"}}}

What exact version of Jetty are you using ?

But you are right, one should be more defensive in the detector, avoiding an NPE when the method can't be found. I fixed this and will soon release a 0.83-SNAPSHOT (this evening). I will also add a safety net for the detectors, that will prevent to block the startup.
... roland
keith-2 keith-2
Reply | Threaded
Open this post in threaded view
|

Re: Running Jolokia in Jetty 6

Re: Running Jolokia in Jetty 6 Hi Roland,

Thanks for the quick response.

I’m running the cargo-maven2-plugin (version 1.0-alpha-5) and configuring it to use Jetty 6 which actually uses jetty-6.1.1rc1

I will try upgrading the version of the plugin to see if this problem disappears.

Keith


On 25/01/2011 15:22, "roland [via Jolokia]" <ml-node+2330732-134769160-329826@...> wrote:

Sorry, I can't reproduce this. I just installed a fresh Jetty 6.1.26 and get the following output when pointing my browser to http://localhost:8080/jolokia

{"timestamp":1295967459,"status":200,"request":{"type":"version"},"value":{"protocol":"4.1","agent":"0.82","info":{"product":"jetty","vendor":"Mortbay","version":"6.1.26"}}}

What exact version of Jetty are you using ?

But you are right, one should be more defensive in the detector, avoiding an NPE when the method can't be found. I fixed this and will soon release a 0.83-SNAPSHOT (this evening). I will also add a safety net for the detectors, that will prevent to block the startup.
... roland

If you reply to this email, your message will be added to the discussion below:
http://jolokia.963608.n3.nabble.com/Running-Jolokia-in-Jetty-6-tp2329096p2330732.html
To unsubscribe from Running Jolokia in Jetty 6, click here < .

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit
http://www.messagelabs.com/email
______________________________________________________________________


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
roland roland
Reply | Threaded
Open this post in threaded view
|

Re: Running Jolokia in Jetty 6

In reply to this post by kbishop
It is also really interesting that the NPE arise within the JVM reflection code:

Caused by: java.lang.NullPointerException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)

As you might have seen, I call the method like

        method.invoke(null);

So, I guess, that the "null" argument causes the trouble. However, from the Java 1.6 doc:

   "If the underlying method is static, then the specified obj argument is ignored. It may be null."

What JVM version are you running on ? If it is 1.5 could you please try with 1.6, too ?
My understanding is, that org.mortbay.jetty.Server.getVersion() is a static method, but I will verify this for different Jetty versions now.

... roland
roland roland
Reply | Threaded
Open this post in threaded view
|

Re: Running Jolokia in Jetty 6

Ok, I got it. In Jetty 6.1.1RC1, getVersion() was an instance method, hence the NPE. I don't know, when they changed it to static, but in 6.1.26 it's a static method. So upgrading Jetty is a good bet for fixing this. I will try to fix the version detection for ancient Jetty versions, too.

Thanks for spotting this ...
... roland
keith-2 keith-2
Reply | Threaded
Open this post in threaded view
|

Re: Running Jolokia in Jetty 6

Re: Running Jolokia in Jetty 6 Hi Roland,

I’ve upgraded the cargo-maven2-plugin to version 1.6.0 and everything works fine.

Keith


On 25/01/2011 16:10, "roland [via Jolokia]" <ml-node+2331382-74173150-329826@...> wrote:

Ok, I got it. In Jetty 6.1.1RC1, getVersion() was an instance method, hence the NPE. I don't know, when they changed it to static, but in 6.1.26 it's a static method. So upgrading Jetty is a good bet for fixing this. I will try to fix the version detection for ancient Jetty versions, too.

Thanks for spotting this ...
... roland

If you reply to this email, your message will be added to the discussion below:
http://jolokia.963608.n3.nabble.com/Running-Jolokia-in-Jetty-6-tp2329096p2331382.html
To unsubscribe from Running Jolokia in Jetty 6, click here < .

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit
http://www.messagelabs.com/email
______________________________________________________________________


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
roland roland
Reply | Threaded
Open this post in threaded view
|

Re: Running Jolokia in Jetty 6

In reply to this post by roland
FYI: I fixed the issue with Jetty < 6.1.4 and deployed the snapshot 0.83-SNAPSHOT on our labs repository.

Please see the Download section for how to include snapshot versions.

Thanks again ...
... roland