我有Sling 8.然后在我的构建中包含Jersey和Jersey连接器:https://github.com/hstaudacher/osgi-jax-rs-connector
我的下一步应该简单地编写一个Jersey服务并测试它,但我立刻得到了这个例外:
27.01.2017 10:54:16.696 *ERROR* [FelixDispatchQueue] com.eclipsesource.jaxrs.publisher FrameworkEvent ERROR (org.osgi.framework.ServiceException: Service factory returned null.)org.osgi.framework.ServiceException: Service factory returned null.
和
[FelixDispatchQueue] com.eclipsesource.jaxrs.publisher FrameworkEvent ERROR (org.osgi.framework.ServiceException: Service factory exception: org/apache/felix/shell/Command)
org.osgi.framework.ServiceException: Service factory exception: org/apache/felix/shell/Command
和
Caused by: java.lang.NoClassDefFoundError: org/apache/felix/shell/Command
所以我看看我在Felix中的捆绑列表,我没有看到任何捆绑似乎提供这个...所以我在网上找到它并自己安装。现在我得到这个例外:
Service factory exception: org/apache/sling/extensions/threaddump/internal/ThreadDumpCommand
和
Caused by: java.lang.NoClassDefFoundError: org/apache/sling/extensions/threaddump/internal/ThreadDumpCommand
和
Caused by: java.lang.NoClassDefFoundError: org/apache/felix/webconsole/plugins/memoryusage/internal/MemoryUsageCommand
现在,我已经安装了这个类的捆绑包(它是“Apache Felix Web控制台内存使用插件”)。所以现在我真的不明白到底发生了什么。
我有一种感觉,我不应该提供我自己的“felix shell”捆绑包,并且Sling中的OSGI未能提供它......
有人成功使用Sling 8和Jersey吗?
答案 0 :(得分:0)
也许你应该为初学者尝试一个vanilla OSGi环境。一旦你有泽西岛工作,那么你可以尝试与Sling集成。
我在OSGi中使用jaxrs取得了成功,特别是使用了Amdatu REST软件包。
https://amdatu.org/application/tutorial/step1/
通过这种方式,我能够使用JAX-RS注释来提供HTTP服务:
你可以看到我在这里使用的包: