Since I updated to Gyrex 1.2, Jetty 9.0.3 and Jersey 1.17.0 my REST Services have a problem. The following Exception occures.
java.lang.NullPointerException
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:681)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:452)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:184)
at org.eclipse.gyrex.http.jetty.internal.app.ApplicationDelegateHandler.doHandle(ApplicationDelegateHandler.java:92)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:211)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1083)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:379)
I debugged into the startup of the JaxRsApplication and it looks like the JaxRsApplication#doInit is called, and a new ServletContainer is registered. But the ServletContainer#init method is never called.
Should I overwrite the JaxRsApplication#doInit method and call ServletContainer#init there? Or is that the responsibility of a module I missed updating the target? Or ???
It does ring a bell. We discovered a similar issue a while back when upgrading from Jetty 9.0.0 to 9.0.3. Something changed in the servlet initialization. I believe that we fixed this one. But can you please open a bug Report for us to investigate? Thanks!
Meanwhile, the workaround you proposed should work in case it's the same problem.