WebListener in HTTP whitboard

5 views
Skip to first unread message

Richard Hierlmeier

unread,
Jan 29, 2026, 9:54:52 AM (2 days ago) Jan 29
to OPS4J

Is it possible to defined a ServletContextListener with HTTP whiteboard?

I defined this service:

@Component(service = ServletContextListener.class)
@HttpWhiteboardListener
@HttpWhiteboardContextSelect("osgi.http.whiteboard.context.path=/app)")
public class MyServletContextListener implements ServletContextListener
{
}

Jetty (pax-web 8.0.33)  logs this exception:

2026-01-29T15:41:50,090 | ERROR | paxweb-config-1-thread-1 | JettyServerWrapper               | 77 - org.ops4j.pax.web.pax-web-jetty - 8.0.33 | Section 4.4.3 of the Servlets specification allows ServletContextListeners to be added only by ServletContainerInitializers, declared in web.xml or web-fragment.xml or by discovery of @WebListener annotated classes
java.lang.UnsupportedOperationException: Section 4.4.3 of the Servlets specification allows ServletContextListeners to be added only by ServletContainerInitializers, declared in web.xml or web-fragment.xml or by discovery of @WebListener annotated classes
at org.ops4j.pax.web.service.spi.servlet.DynamicRegistrations.register(DynamicRegistrations.java:322) ~[?:?]
at org.ops4j.pax.web.service.spi.servlet.DynamicRegistrations.addListener(DynamicRegistrations.java:293) ~[?:?]
at org.ops4j.pax.web.service.spi.servlet.OsgiDynamicServletContext.addListener(OsgiDynamicServletContext.java:139) ~[?:?]
at org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer.onStartup(WebSocketServerContainerInitializer.java:278) ~[?:?]
at org.ops4j.pax.web.service.spi.servlet.SCIWrapper.onStartup(SCIWrapper.java:43) ~[?:?]
at org.ops4j.pax.web.service.jetty.internal.PaxWebServletContextHandler.lambda$startContext$1(PaxWebServletContextHandler.java:258) ~[?:?]
at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
at org.ops4j.pax.web.service.jetty.internal.PaxWebServletContextHandler.startContext(PaxWebServletContextHandler.java:252) ~[?:?]
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:916) ~[?:?]
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:288) ~[?:?]
at org.ops4j.pax.web.service.jetty.internal.PaxWebServletContextHandler.doStart(PaxWebServletContextHandler.java:308) ~[?:?]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73) ~[?:?]
at org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper.ensureServletContextStarted(JettyServerWrapper.java:2436) ~[?:?]
at org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper.lambda$visitWebSocketModelChange$20(JettyServerWrapper.java:1929) ~[?:?]
at java.util.ArrayList.forEach(ArrayList.java:1596) ~[?:?]
at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1116) ~[?:?]
at org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper.visitWebSocketModelChange(JettyServerWrapper.java:1914) ~[?:?]
at org.ops4j.pax.web.service.spi.task.WebSocketModelChange.accept(WebSocketModelChange.java:90) ~[?:?]
at org.ops4j.pax.web.service.spi.task.Batch.accept(Batch.java:430) ~[?:?]
at org.ops4j.pax.web.service.jetty.internal.JettyServerController.sendBatch(JettyServerController.java:169) ~[?:?]
at org.ops4j.pax.web.service.internal.HttpServiceEnabled.lambda$doRegisterWebSocket$20(HttpServiceEnabled.java:1968) ~[?:?]
at org.ops4j.pax.web.service.spi.model.ServerModel.lambda$run$2(ServerModel.java:541) ~[?:?]
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572) ~[?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:317) ~[?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[?:?]
at java.lang.Thread.run(Thread.java:1583) [?:?]

Grzegorz Grzybek

unread,
Jan 29, 2026, 10:05:56 AM (2 days ago) Jan 29
to op...@googlegroups.com
Hello

This is strange, because the error is caused by org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer, and not by your listener...

Also Pax Web has integration tests that use websockets with Jetty and this scenario was verified.

Please create a GitHub issue - it'd be great checking some reproducer.

kind regards
Grzegorz Grzybek

--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ops4j/ad234bbe-b8cd-4d14-8c89-364fd28fb3aen%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages