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:

FINE: Error parsing HTTP request header
java.io.EOFException
at 
org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.fillReadBuffer(NioEndpoint.java:1239)
at 
org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.read(NioEndpoint.java:1139)
at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:735)
at 
org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:353)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:292)
at 
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at 
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860)
at 
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587)
at 
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at 
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

Thanks for your help & best regards
Alex

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to