jetty / jetty.project

Eclipse Jetty® - Web Container & Clients - supports HTTP/2, HTTP/1.1, HTTP/1.0, websocket, servlets, and more
https://eclipse.dev/jetty
Other
3.83k stars 1.91k forks source link

NPE in websocket extension startup #10168

Closed RangerRick closed 1 year ago

RangerRick commented 1 year ago

Jetty version(s)

9.4.51.v20230217

Java version/vendor (use: java -version)

JDK 11, various, currently:

openjdk version "11.0.18" 2023-01-17
OpenJDK Runtime Environment (build 11.0.18+10-post-Ubuntu-0ubuntu122.04)
OpenJDK 64-Bit Server VM (build 11.0.18+10-post-Ubuntu-0ubuntu122.04, mixed mode)

OS type/version

various

Description

We are seeing an intermittent issue starting up Jetty in an OSGi (Karaf) environment. It appears to be a race condition of some kind.

2023-07-27T21:53:46,627 | ERROR | paxweb-config-4-thread-1 | HttpServiceStarted               | 139 - org.ops4j.pax.web.pax-web-runtime - 7.3.23 | Could not start the servlet context for context path []
java.lang.NullPointerException: null
    at org.eclipse.jetty.websocket.api.extensions.ExtensionFactory.<init>(ExtensionFactory.java:40) ~[?:?]
    at org.eclipse.jetty.websocket.common.extensions.WebSocketExtensionFactory.<init>(WebSocketExtensionFactory.java:51) ~[?:?]
    at org.eclipse.jetty.websocket.server.WebSocketServerFactory.<init>(WebSocketServerFactory.java:188) ~[?:?]
    at org.eclipse.jetty.websocket.server.WebSocketServerFactory.<init>(WebSocketServerFactory.java:144) ~[?:?]
    at org.eclipse.jetty.websocket.server.WebSocketServerFactory.<init>(WebSocketServerFactory.java:123) ~[?:?]
    at org.eclipse.jetty.websocket.server.NativeWebSocketConfiguration.<init>(NativeWebSocketConfiguration.java:51) ~[?:?]
    at org.eclipse.jetty.websocket.server.NativeWebSocketServletContainerInitializer.initialize(NativeWebSocketServletContainerInitializer.java:63) ~[?:?]
    at org.eclipse.jetty.websocket.server.NativeWebSocketServletContainerInitializer.onStartup(NativeWebSocketServletContainerInitializer.java:122) ~[?:?]
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext$1.call(HttpServiceContext.java:219) ~[?:?]
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext$1.call(HttpServiceContext.java:214) ~[?:?]
    at org.ops4j.pax.swissbox.core.ContextClassLoaderUtils.doWithClassLoader(ContextClassLoaderUtils.java:60) ~[?:?]
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.lambda$doStart$1(HttpServiceContext.java:213) ~[?:?]
    at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doStart(HttpServiceContext.java:211) ~[?:?]
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73) ~[?:?]
    at org.ops4j.pax.web.service.jetty.internal.JettyServerImpl$1.start(JettyServerImpl.java:327) ~[?:?]
    at org.ops4j.pax.web.service.internal.HttpServiceStarted.registerServlet(HttpServiceStarted.java:255) ~[?:?]
    at org.ops4j.pax.web.service.internal.HttpServiceStarted.registerServlet(HttpServiceStarted.java:226) ~[?:?]
    at org.ops4j.pax.web.service.internal.HttpServiceStarted.registerServlet(HttpServiceStarted.java:210) ~[?:?]
    at org.ops4j.pax.web.service.internal.HttpServiceProxy.registerServlet(HttpServiceProxy.java:69) ~[?:?]
    at org.jolokia.osgi.JolokiaActivator$HttpServiceCustomizer.addingService(JolokiaActivator.java:322) ~[?:?]
    at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:943) ~[osgi.core-7.0.0.jar:?]
    at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:871) ~[osgi.core-7.0.0.jar:?]
    at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) ~[osgi.core-7.0.0.jar:?]
    at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229) ~[osgi.core-7.0.0.jar:?]
    at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:903) ~[osgi.core-7.0.0.jar:?]
    at org.apache.felix.framework.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:990) ~[?:?]
    at org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:838) ~[?:?]
    at org.apache.felix.framework.EventDispatcher.fireServiceEvent(EventDispatcher.java:545) ~[?:?]
    at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4833) ~[?:?]
    at org.apache.felix.framework.Felix.registerService(Felix.java:3804) ~[?:?]
    at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:328) ~[?:?]
    at org.ops4j.pax.web.service.internal.Activator.updateController(Activator.java:381) ~[?:?]
    at org.ops4j.pax.web.service.internal.Activator.lambda$scheduleUpdateFactory$1(Activator.java:299) ~[?:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
    at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
    at java.lang.Thread.run(Thread.java:829) [?:?]

As far as I can tell, this likely does not happen in Jetty 10 as the WebSocketExtensionRegistry that replaces the 9.4.x ExtensionFactory limits the service loader to the current class's classloader, and there are a number of implementations of the Extension interface already in the classpath.

How to reproduce?

We see it occasionally, when starting up one of our Karaf instances at OpenNMS. Have not been able to reliably reproduce it as of yet.

joakime commented 1 year ago

Jetty 9.x is now at End of Community Support.

joakime commented 1 year ago

PR #10169 merged