My current web server is embedded Jetty 9.1.5. It works well with JSR-356 to create websocket. These days, I am trying to upgrade to Jetty 9.4.1. Everything works nicely exc
Judging from your setup, you'll wind up with ...
wss://localhost:8443/myContext/ws/communication/5/kbui/None
Your contextPath isn't /context, its actually /myContext in your setup.
You trimmed out the Servlet Mappings section on the dump (that was the important part. heh)
But attempting to manually add the WSCommunication Endpoint contained in WebAppContext from outside of the WebAppClassloader or the WebApp's ServletContext is probably going to be a problem as well.
You have 3 options:
The JSR356 Automatic Way
Setup bytecode scanning and annotation discovery for your WebAppContext and let the startup discover and auto-load the WSCommunication endpoint.
Add the following to your webContext ...
webContext.setAttribute("org.eclipse.jetty.websocket.jsr356",Boolean.TRUE);
webContext.setConfigurations(new Configuration[] {
new AnnotationConfiguration(),
new WebXmlConfiguration(),
new WebInfConfiguration(),
new PlusConfiguration(),
new MetaInfConfiguration(),
new FragmentConfiguration(),
new EnvConfiguration()});
And add the jetty-annotations dependency to your project.
The JSR356 Manual Way
Use the javax.websocket.server.ServerApplicationConfig to report the WSCommunication as being available to be added from within the webapp's startup.
The Servlet Spec Manual Way
This is the easiest approach.
Create a javax.servlet.ServletContextListener that adds the WSCommunication endpoint to the ServerContainer
public class MyContextListener implements ServletContextListener
{
@Override
public void contextDestroyed(ServletContextEvent sce)
{
}
@Override
public void contextInitialized(ServletContextEvent sce)
{
ServerContainer container = (ServerContainer)sce.getServletContext()
.getAttribute(ServerContainer.class.getName());
try
{
container.addEndpoint(WSCommunication.class);
}
catch (DeploymentException e)
{
throw new RuntimeException("Unable to add endpoint",e);
}
}
}