2

My code -> package X (3rd party package) -> org.apache.commons.lang 2.6.0
My code -> package Y (3rd party package) -> org.apache.commons.lang 2.4

I have control on neither package X bundle nor package Y bundle.

Here is the error I have:

02.04.2017 08:02:12.315 *INFO* [OsgiInstallerImpl] org.apache.sling.installer.core.impl.tasks.RestartActiveBundlesTask Unable to start bundle com.mynews.my-wcm-bundle [394] : Uses constraint violation. Unable to resolve bundle revision com.mynews.my-wcm-bundle [394.11] because it is exposed to package 'org.apache.commons.lang.math' from bundle revisions com.mynews.my-wcm-dependencies-bundle [395.39] and com.day.commons.osgi.wrapper.commons-lang2 [45.0] via two dependency chains.

**Chain 1:**
  com.mynews.my-wcm-bundle [394.11]
    import: (&(osgi.wiring.package=org.apache.commons.lang.math)(version>=2.6.0)(!(version>=3.0.0)))
     |
    export: osgi.wiring.package=org.apache.commons.lang.math
  com.mynews.my-wcm-dependencies-bundle [395.39]

**Chain 2:**
  com.mynews.my-wcm-bundle [394.11]
    import: (osgi.wiring.package=com.day.cq.security)
     |
    export: osgi.wiring.package=com.day.cq.security; uses:=com.day.cq.commons
  com.day.cq.cq-security-api [283.0]
    import: (osgi.wiring.package=com.day.cq.commons)
     |
    export: osgi.wiring.package=com.day.cq.commons; uses:=org.apache.commons.lang.time
  com.day.cq.cq-commons [264.0]
    import: (&(osgi.wiring.package=org.apache.commons.lang.time)(version>=2.4.0)(!(version>=3.0.0)))
     |
    export: osgi.wiring.package=org.apache.commons.lang.time; uses:=org.apache.commons.lang.math
    export: osgi.wiring.package=org.apache.commons.lang.math
  com.day.commons.osgi.wrapper.commons-lang2 [45.0]

2 Answers 2

2

If you look at the chains you can see that one bundle requires commons lang version [2.4,3) and another requires version [2.6,3). So if you make sure you only install commons lang 2.6 then your bundle should resolve.

5
  • I agree, but commons lang 2.4 is needed by some 3rd party jars, so I have to keep 2.4.
    – Srini N
    Apr 3, 2017 at 16:23
  • In this case I think you can not solve it using your current set of bundles. Maybe an upgrade of the 3rd party libs can help. In general try to not expose third party apis in your own bundles. As this is what really makes those chains problematic. Apr 4, 2017 at 8:52
  • 2
    What does it mean "Try to not expose third party apis in your own bundles"? a) Not to include 3rd party packages in my bundle with <Export-Package> ? OR b) Not to embed 3rd party jars with <Embed-Dependency>
    – Srini N
    Apr 4, 2017 at 10:59
  • It means that the packages in your bundle that are exported should not use classes from packages you import. In your case it looks like you used something from commons time in the packages you export. This exposes the bundle that imports your package to the commons time classes and in the end this is what causes the uses constraint violations. Apr 4, 2017 at 13:00
  • You said "the packages in your bundle that are exported should not use classes from packages you import". Trying to understand this statement. If you see this screenshot, screencast.com/t/tXlOezrROhz, my package name is com.aprilcompany.aprilproject. It requires some 3rd party packages, I am importing them through my dependencies bundle. I feel that, export and import is necessary here.
    – Srini N
    Apr 4, 2017 at 21:06
0

I would suggest uninstall those bundles from your fuse/karaf and install a feature or a bundle which already exports those 2 dependencies.

I had a similar problem with com.google.zxing (version 3.2.1) where there is the 'core' and the 'javase' artifacts. Fuse/karaf has showed this "chain error".

What I did to solve it was to install a bundle which already exported them.

install mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.zxing/3.2.1_1

As a last resort I would create a feature myself and deploy it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.