3

I am trying to get a Tomcat server (7.0.54) to support WebSocket and having a hard time deploying it. I have a simple endpoint:

@ServerEndpoint(value = "/test") public class TestEndpoint {

In order to have this endpoint processed, I need to include a container (which uses ServiceLoader to start, introspect all the classes with endpoint annotations, etc...). I use the following:

<dependency> <groupId>org.apache.tomcat</groupId> <artifactId>tomcat7-websocket</artifactId> <version>7.0.47</version> </dependency>

However, mvn tomcat7:run then fails to start with:

SEVERE: Parse error in application web.xml file at jndi:/localhost/WEB-INF/web.xml org.xml.sax.SAXParseException; systemId: jndi:/localhost/WEB-INF/web.xml; lineNumber: 13; columnNumber: 12; Error at (13, 12) : org.apache.catalina.deploy.WebXml addFilter

If instead, I specify the scope as system and I point it to my local file system:

<dependency> <groupId>org.apache.tomcat</groupId> <artifactId>tomcat7-websocket</artifactId> <version>7.0.47</version> <scope>system</scope> <systemPath>${somewhere}/tomcat7-websocket-7.0.54.jar</systemPath> </dependency>

... then everything works fine, but of course, this can't be reliably deployed on a live server.

What can I do to start my WebSocket container properly?

1 Answer 1

4

You need to use this dependency and marked it as provided (and not the one coming from org.apache.tomcat never included tomcat dependency as it's all provided by the container). That's similar to servlet-api:

<dependency>
  <groupId>javax.websocket</groupId>
  <artifactId>javax.websocket-api</artifactId>
  <version>1.0</version>
  <scope>provided</scope>
</dependency>
1
  • That did it, except I had to add the scope to org.apache.tomcat:tomcat7-websocket, which is the one I'm using. Thanks Olivier! Jul 10, 2014 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.