问题
I am attempting to deploy Tyrus to a Tomcat 8 container and am failing. According to the documentation, I should be able to deploy a WAR containing my classes and supporting Tyrus classes/dependencies and all classes annotated with @ServerEndpoint should be found in the WAR and deployed as websocket end points. This instruction threw me a little because I'm not defining any sort of filter in the deployment descriptor but decided that I must be somehow depending on some unknown magic in the support of JSR 356 in Tomcat 8. As it turns out, there is no such magic. NOTE: I'm using Tomcat 8 because my understanding is that it supports the JSR 356 websocket standard. Also, my JDK is the latest Java 7 version.
I have spent some time researching this and have found that people are successful in publishing websocket end points with Tyrus by running an instance of a Server (org.glassfish.tyrus.server.Server) as a Java application from the command line. I have tried this and it works. However, I'm unable to find any success deploying a WAR on Tomcat.
Does anyone have any insight into the steps required to successfully publish websocket end points via Tyrus on Tomcat 8?
回答1:
Apache Tomcat 7.0 and later (and Eclipse Jetty 9.1) has built-in support for JSR-356 (aka javax.websocket
).
There is no need to use the Tyrus compatibility layer on most JEE7 containers.
Just skip the entire Tyrus configuration issue and use the built-in features that expose javax.websocket
support.
- Jetty 9+
- Tomcat 8 How-To
- Tomcat 7 How-To
来源:https://stackoverflow.com/questions/20646663/how-to-deploy-tyrus-jsr-356-implementation-to-a-web-container