如何将Tyrus(JSR 356实现)部署到Web容器?

编程入门 行业动态 更新时间:2024-10-27 11:28:45
本文介绍了如何将Tyrus(JSR 356实现)部署到Web容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试将Tyrus部署到Tomcat 8容器,但是失败了。根据文档,我应该能够部署包含我的类并支持Tyrus类/依赖项的WAR,并且所有用@ServerEndpoint注释的类都应该在WAR中找到并部署为websocket端点。该指令让我有些不满意,因为我没有在部署描述符中定义任何类型的过滤器,而是决定必须以某种未知的方式依赖于Tomcat 8中对JSR 356的支持。事实证明,没有任何方法可以解决。如此神奇。注意:我使用的是Tomcat 8,因为我的理解是它支持JSR 356 websocket标准。另外,我的JDK是Java 7的最新版本。

我花了一些时间对此进行了研究,并发现人们可以通过运行Tyrus成功地通过Tyrus发布websocket端点。命令行中作为Java应用程序的Server(org.glassfish.tyrus.server.Server)服务器实例。我已经尝试过了,并且有效。但是,我找不到在Tomcat上部署WAR的任何成功。

是否有人对通过Tyrus在Tomcat上成功发布Websocket端点所需的步骤有任何了解? 8?

解决方案

Apache Tomcat 7.0和更高版本(以及Eclipse Jetty 9.1)具有对JSR-356(又名 javax.websocket )。

在大多数JEE7容器上都不需要使用Tyrus兼容性层。

只需跳过整个Tyrus配置问题,并使用提供 javax.websocket 支持的内置功能。

  • Jetty 9+
  • Tomcat 8使用方法
  • Tomcat 7使用方法

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?

解决方案

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

更多推荐

如何将Tyrus(JSR 356实现)部署到Web容器?

本文发布于:2023-10-07 17:06:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1469972.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   容器   Tyrus   JSR   Web

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!