简体   繁体   中英

OSGI bundle exception, maven dependency issue

I'm pretty new to the OSGI, Felix and Maven stuffs, just started with it. I'm deploying the java build through jenkins and I get the below dependency issue.

Below is the pom file contents which includes the dependency, I'm not sure whether it is correct, but it still complains about it.

It is looking for "javax.jws" and the version is between 2.0 and 3.0

javax.jws;version>="2.0.0",!javax.jws;version>="3.0.0"

Below is the pom contents.

                            <Import-Package>!sun.misc,!org.apache.avalon.framework.logger,
    !org.ietf.jgss,!org.apache.log,!org.apache.log.format,!org.apache.log.output.io,!com.werken.xpath,!org.apache.tools.ant,!org.apache.tools.ant.taskdefs,
    !org.jdom,!org.jdom.input,!org.jdom.output,com.mblox.ngp.sal*;
    version="${sal-utils-version}",org.apache.commons.logging;version="1.1",
    javax.jws;version>="2.0.0",!javax.jws;version>="3.0.0",
    com.sun.xml.ws.api.message,*
</Import-Package>

Below is the exception that I get:

[#|2013-01-29 11:07:44,109|ERROR|NGP-SAL-SALBootstrap-SAL-0|com.mblox.ngp.sal.platform.impl.Sal|172.18.36.38|slodev-rhatf4.mblox.com|sal-1|Unresolved constraint in bundle sap-ws-netcom [24]: Un
able to resolve 24.0: missing requirement [24.0] package; (&(package=javax.jws)(version>=2.0.0)(version>=2.0.0)(!(version>=3.0.0))) - [24.0] package; (&(package=javax.jws)(version>=2.0.0)(versi
on>=2.0.0)(!(version>=3.0.0)))|#]
org.osgi.framework.BundleException: Unresolved constraint in bundle sap-ws-netcom [24]: Unable to resolve 24.0: missing requirement [24.0] package; (&(package=javax.jws)(version>=2.0.0)(version
>=2.0.0)(!(version>=3.0.0))) - [24.0] package; (&(package=javax.jws)(version>=2.0.0)(version>=2.0.0)(!(version>=3.0.0)))
        at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3421)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:1754)
        at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:905)
        at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:892)
        at com.mblox.ngp.sal.platform.impl.Sal.installBundle(Sal.java:608)
        at com.mblox.ngp.sal.platform.impl.Sal.getBundle(Sal.java:481)
        at com.mblox.ngp.sal.platform.impl.Sal.installSap(Sal.java:630)
        at com.mblox.ngp.sal.platform.impl.Sal.initSapBundles(Sal.java:545)
        at com.mblox.ngp.sal.platform.impl.Sal.start(Sal.java:290)
        at com.mblox.ngp.sal.platform.impl.SALBootstrap.call(SALBootstrap.java:64)
        at com.mblox.ngp.sal.platform.impl.SALBootstrap.call(SALBootstrap.java:24)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)

Any suggestions or pointers to solve this issue.

Is there any bundle which exports the javax.jws package? If not, you can add this Maven dependency to your build and also make sure it is deployed to Felix:

<dependency>
    <groupId>org.apache.geronimo.specs</groupId>
    <artifactId>geronimo-ws-metadata_2.0_spec</artifactId>
    <version>1.1.2</version>
</dependency>

Everything appears to be as expected. You have configured the sap-ws-netcom bundle pom to declare a need for the j avax.jws package. And the container is trying to find it while it's trying to resolve the dependency.

org.osgi.framework.BundleException: Unresolved constraint in bundle sap-ws-netcom [24]: Unable to resolve 24.0: missing requirement [24.0] package; (&(package=javax.jws)(version>=2.0.0)(version
>=2.0.0)(!(version>=3.0.0))) - [24.0] package; (&(package=javax.jws)(version>=2.0.0)(version>=2.0.0)(!(version>=3.0.0)))
        at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3421)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:1754)

The problem is simple, the OSGi container doesn't have javax.jws available, at least not in the versions you are asking for. Did you think that you had made it available?

The way you make it available is by installing a bundle that exports that package. You must do this yourself. This is generally the case with OSGi; if you don't explicitly make the java package available, then it's not there.

I also had a problem with javax.jws dependencies using Felix within CQ5 and the solution (strangely) is to explicitly not include javax.jws and javax.jws.soap in the Import-Package part of the bundle manifest. If you're using the maven-bundle-plugin (as I am) you can use the following in the instructions:

<plugin>
<groupid>org.apache.felix</groupid>
<artifactid>maven-bundle-plugin</artifactid>
<version>2.1.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<import-package>!javax.jws,!javax.jws.soap,*</import-package> 
</instructions>
</configuration>
</plugin>

I also did not need to have a separate bundle which exports javax.jws and javax.jws.soap. Simply doing the above for my bundle which had the web service client code (generated with wsimport) was enough to make it work.

One other thing, I had to do was to add

sling.bootdelegation.com.sun=com.sun.*

to the sling.properties file.

The CQ5 tutorial on creating webservices mentions it on this page: http://helpx.adobe.com/adobe-cq/using/creating-cq-bundles-consume-web.html

"Note:

This workflow works on Adobe CQ; however, you may encounter the following exception:

Caused by: java.lang.ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl at org.apache.sling.commons.classloader.impl.ClassLoaderFacade.loadClass(ClassLoaderFacade.java:127) at java.lang.ClassLoader.loadClass(Unknown Source) at javax.xml.ws.spi.FactoryFinder.safeLoadClass(Unknown Source) ... 107 more Solution: To fix this issue and ensure that you can create a bundle that consumes web services as described in this article, modify the sling.properties file located in the crx-quickstart\\conf folder. Add the following line of code to this file: sling.bootdelegation.com.sun=com.sun.*. Then restart the server. Once you perform this task, you can follow along with this article."

If you're running Windows, try putting it in C:\\G\\ or a shorter path name. it fixed the problem for me!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM