diff --git a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/config/JavaxWebSocketServletContainerInitializer.java b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/config/JavaxWebSocketServletContainerInitializer.java index af4cca34fe31..576fd96ad288 100644 --- a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/config/JavaxWebSocketServletContainerInitializer.java +++ b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/config/JavaxWebSocketServletContainerInitializer.java @@ -99,6 +99,9 @@ public interface Configurator */ public static void configure(ServletContextHandler context, Configurator configurator) { + if (!context.isStopped()) + throw new IllegalStateException("configure should be called before starting"); + // In this embedded-jetty usage, allow ServletContext.addListener() to // add other ServletContextListeners (such as the ContextDestroyListener) after // the initialization phase is over. (important for this SCI to function) diff --git a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/config/JettyWebSocketServletContainerInitializer.java b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/config/JettyWebSocketServletContainerInitializer.java index 4740fbc75f88..a8d19f58035f 100644 --- a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/config/JettyWebSocketServletContainerInitializer.java +++ b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/config/JettyWebSocketServletContainerInitializer.java @@ -53,6 +53,9 @@ public interface Configurator */ public static void configure(ServletContextHandler context, Configurator configurator) { + if (!context.isStopped()) + throw new IllegalStateException("configure should be called before starting"); + context.addEventListener( ContainerInitializer .asContextListener(new JettyWebSocketServletContainerInitializer())