Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Java EE 7 WebSockets in Tomcat 7

Java EE 7 is out and one the features that I like is the standard Websockets. Currently I work in Tomcat 7, Is there a way to integrate Java EE 7 Websockets in my Tomcat 7? I searched for it in the documentation of Tyrus Websocket with no success

UPDATE: Tomcat 7.0.47 comes with Websocket support, yeah baby!

like image 233
Nestor Hernandez Loli Avatar asked Jul 11 '13 18:07

Nestor Hernandez Loli


Video Answer


1 Answers

It won't be possible to take the Tyrus WebSocket implementation and use it in Tomcat 7. It might work in Tomcat 8 but it is unlikely as there are some issues with WebSocket that means it is impossible to implement WebSocket directly on top of the Servlet 3.1 API unless the Servlet 3.1 implementation bends some rules. (As an aside, I'll be talking about this at JavaOne this year). As far as I know, most implementations are using container specific APIs to work-around these issues (and for better performance).

Tomcat's Java WebSocket 1.0 (JSR-356) implementation is currently only available in Tomcat 8. It has always been the plan to back-port that implementation to Tomcat 7 once it was stable. I think that point is close. The implementation has been passing the Autobahn TestSuite for both client and server for some time. In the last few days some folks have been stress-testing it and have found a few issues - all of which have been fixed.

Today, you'll need to build Tomcat 8 from source to get a Tomcat based JSR-356 implementation. Some time in the next few releases (there is a new Tomcat 7 release roughly every month) the JSR-356 implementation will be available in Tomcat 7 as well.

If you don't want to build from source, I believe Glassfish is your only option at this point for a JSR-356 implementation. I know Jetty and JBoss are working on one but I don't know how close they are to completion.

like image 104
Mark Thomas Avatar answered Sep 21 '22 03:09

Mark Thomas