On 04/11/2019 12:59, Alexander Stöcker wrote:
> My code is basically just:
>
> Tomcat tomcat = new Tomcat();
> tomcat.getConnector();
> tomcat.setPort(8080);
>
> Context context = tomcat.addContext("/context", new
> File(".").getAbsolutePath());
>
> // servlet
> Tomcat.addServlet(context, "myServlet", new MyServlet());
> context.addServletMappingDecoded("/hello", "myServlet");
>
> // websocket
> context.addApplicationListener(MyWSContextListener.class.getName());
>
> // run
> tomcat.start();
> tomcat.getServer().await();
>
>
> The WsContextListener is adding an Endpoint when contextInitialized()
> is called. Setting a Breakpoint shows that the code is actually
> executed. The Servlet is working but when I'm trying to connect to the
> endpoint ("ws://localhost:8080/context/endpoint") I get a 404. On Fine
> debug output I can see, that this exception is thrown, whenever a
> connection is requested:
You need to configure the default servlet. Otherwise the mapper looks at
the URI, sees that it doesn't match any known servlets and rejects the
request with a 404 before the WebSocket filter has a chance to handle
the request.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]