error when deploying jersey/helloworld-osgi-webapp on glassfish 3.1.2.2

偶尔善良 提交于 2020-01-05 07:49:09

问题



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

Why maven felix plugin is not embedding the libraries in the war ?
Thanx in advance, M.


回答1:


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.

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>

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>

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.



来源:https://stackoverflow.com/questions/14939901/error-when-deploying-jersey-helloworld-osgi-webapp-on-glassfish-3-1-2-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!