【发布时间】:2017-03-03 12:33:12
【问题描述】:
我目前使用 tyrus 客户端实现了 websocket 客户端,并且 websockets 客户端在 OSGI 环境之外可以正常工作。
问题是 websocket 不能在 apache karaf 上运行。 我已经安装了 websocket 客户端的所有依赖项。列表是
ID | State | Lvl | Version | Name
------------------------------------------------------------------------------------
52 | Active | 80 | 4.3.0 | Apache Felix Dependency Manager
96 | Active | 80 | 1.0 | WebSocket server API
97 | Active | 80 | 1.1.0 | Tyrus Server
98 | Active | 80 | 1.1.0 | Tyrus Core
99 | Active | 80 | 1.1.0 | Tyrus Container SPI
100 | Active | 80 | 1.1.0 | Tyrus WebSocket Core
102 | Active | 80 | 1.1.0 | Tyrus Grizzly Container
103 | Active | 80 | 2.3.3 | grizzly-framework
104 | Active | 80 | 2.3.3 | grizzly-http
105 | Active | 80 | 2.3.3 | grizzly-http-server
106 | Active | 80 | 2.3.3 | grizzly-rcm
118 | Active | 80 | 1.0.8 | Apache Aries SPI Fly Dynamic Weaving Bundle
134 | Active | 80 | 1.1.0 | Tyrus Client
135 | Installed | 80 | 1.0.0.SNAPSHOT | rna-websocket-client
tyrus 客户端通过 ServiceLoader 提供实现。 所以我使用 Apache Aries SPI Fly Dynamic Weaving Bundle 来实现。但我仍然收到 Could not find an implementation class. 错误。
调查发现tyrus客户端没有添加
Provide-Capability: osgi.serviceloader; osgi.serviceloader="javax.websocket.ContainerProvider"
到需要通知处理包有关正在提供的服务的清单。 在我的 rna-websocket-client 包中,我添加了
<Require-Capability>osgi.serviceloader; filter:="(osgi.serviceloader=javax.websocket.ContainerProvider)";cardinality:=multiple,osgi.extender; filter:="(osgi.extender=osgi.serviceloader.processor)"</Require-Capability>.
这需要通知 aries 动态编织包我们使用 javax.websocket.ContainerProvider 服务。
这是在 OSGI 中运行 websockets 的正确方法还是在 OSGI 中运行 websockets 的任何其他方法? 对这个问题的任何见解都会非常有帮助。
【问题讨论】:
标签: java websocket osgi apache-karaf tyrus