Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE on WebSocketServerContainerInitializer.configureContext(ServletContextHandler) #3139

Closed
joakime opened this issue Nov 23, 2018 · 0 comments
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@joakime
Copy link
Contributor

joakime commented Nov 23, 2018

If the ServletContextHandler isn't added to the Server yet, and you use WebSocketServerContainerInitializer.configureContext(context) like this ...

        Server server = new Server(8080);

        HandlerList handlers = new HandlerList();

        ServletContextHandler context = new ServletContextHandler(
                ServletContextHandler.SESSIONS);
        context.setContextPath("/");
        handlers.addHandler(context);

        // Enable javax.websocket configuration for the context
        ServerContainer wsContainer = WebSocketServerContainerInitializer.configureContext(context);

        // Add your websockets to the container
        wsContainer.addEndpoint(EchoJsrSocket.class);

        handlers.addHandler(new DefaultHandler());

        server.setHandler(handlers);
        server.start();

You'll get a NPE

Exception in thread "main" java.lang.NullPointerException
	at org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer.configureContext(WebSocketServerContainerInitializer.java:148)
	at org.eclipse.jetty.embedded.WebSocketJsrServer.main(WebSocketJsrServer.java:63)
@joakime joakime self-assigned this Nov 23, 2018
@joakime joakime added the Bug For general bugs on Jetty side label Nov 23, 2018
lachlan-roberts added a commit to lachlan-roberts/jetty.project that referenced this issue Dec 14, 2018
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit to lachlan-roberts/jetty.project that referenced this issue Dec 17, 2018
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
@joakime joakime closed this as completed in a703fc6 Jan 8, 2019
joakime added a commit that referenced this issue Jan 8, 2019
…ocket-sci

Fixes #3139 - NPE in WebSocketContainerInitializer
lachlan-roberts added a commit to lachlan-roberts/jetty.project that referenced this issue Jan 9, 2019
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit to lachlan-roberts/jetty.project that referenced this issue Jan 24, 2019
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit to lachlan-roberts/jetty.project that referenced this issue Jan 25, 2019
…eContext

If configure context is called with a context that does not yet have
a server, we should just throw an ISE. This is better than having a
different configuration result depending on if the context has been set
been added to the handler tree or not.

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
gregw added a commit that referenced this issue Jan 28, 2019
…ebsocket-sci

Issue #3139 - NPE in WebSocketContainerInitializer for jetty10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

No branches or pull requests

1 participant