Saturday 15 August 2015

sockets - Java + TomEE. Websockets and Servlets in one project? -



sockets - Java + TomEE. Websockets and Servlets in one project? -

i'm writing simple game javaee websocket technology. using jsr356, server-side socket class looks following:

@serverendpoint( value = "/sock", decoders = { socketdecoder.class } ) public class cardssocket { .... @onmessage public void onmessage(final socketinput message, final session session) { ... } ... }

it works fine, , has no issues. decided create web page info , stuff. so, without changing on previous class, have created new one:

@serverendpoint(value = "/cards") public class cardswebpage extends httpservlet { @override public void doget(...) { ... } }

and configured web.xml file in web-inf directory.

<?xml version="1.0" encoding="utf-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1" metadata-complete="true"> <servlet> <servlet-name>cardswebpage</servlet-name> <servlet-class>server.cardswebpage</servlet-class> </servlet> <servlet-mapping> <servlet-name>cardswebpage</servlet-name> <url-pattern>/cards</url-pattern> </servlet-mapping> </web-app>

and there began troubles. servelet works - browser shows page on localhost:8080/cards, client-side socket class can no longer initiate - falls exception:

"javax.websocket.deploymentexception: http response server [http/1.1 404 not found] did not permit http upgrade websocket"

, , nil seems prepare it. have missed documentation? impossible single project contain both servlets , websocket classes? because, if delete web.xml file, sockets starting work before. server startup logs containing no warnings or errors in both cases.

yeah, perhaps sparks right, , should deploy multiple projects.

java sockets servlets tomee

No comments:

Post a Comment