问题
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