问题描述
尝试部署样本jersey war捆绑代码(在git上的helloworld-osgi-webapp)时:在Glassfish 3.1.2.2上的https://github.com/jersey/jersey-1.x/tree/master/jersey/samples/helloworld-osgi-webapp ),我收到以下osgi错误:
When trying to deploy the sample jersey war bundle code (helloworld-osgi-webapp on git: https://github.com/jersey/jersey-1.x/tree/master/jersey/samples/helloworld-osgi-webapp) on Glassfish 3.1.2.2, I am getting the following osgi error:
remote failure: Error occurred during deployment: Exception while loading the app:
org.osgi.framework.BundleException: Unresolved constraint in bundle war-bundle [344]:
Unable to resolve 344.0: missing requirement [344.0] osgi.wiring.package; (&(osgi.wiring.package=com.sun.jersey.api.core)(version>=1.18.0)(!(version>=2.0.0))).
Please see server.log for more details.
Command deploy failed
为什么maven felix插件未在战争中嵌入库?
提前感谢,M.
Why maven felix plugin is not embedding the libraries in the war ?
Thanx in advance,M.
推荐答案
直接原因是在您的应用程序中未对其进行配置,而不是在OSGi世界中不应该这样做.
Direct reason is that in your application it's not configured to do that, and the reason it's not is that in OSGi world it shouldn't.
来自 pom 处于提供的范围内:
From pom that it is in provided scope:
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
<classifier>cobertura</classifier>
它只会嵌入运行时&编译范围:
And it will only embed runtime & compiled scopes:
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
并使用OSGi标准导入包将jersey-servlet依赖项作为OSGi服务导入:
and uses OSGi standard import-package to import jersey-servlet dependencies as OSGi services:
<Import-Package>com.sun.jersey.api.core,com.sun.jersey.spi.container.servlet,*</Import-Package>
在OSGi世界中,依赖项应作为独立的OSGi捆绑软件部署,而不应嵌入战争中.这就是您的示例正在做的事情.因此,您应该将jersey部署为单独的OSGi捆绑包.
In the OSGi world, dependencies should be deployed as separate OSGi bundles, and not embedded in wars. That's what your example is doing. So, you should deploy jersey as a separate OSGi bundle.
这篇关于在glassfish 3.1.2.2上部署jersey/helloworld-osgi-webapp时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!