0

I have Bundle A that depends on guava version 18 and bundle B that depends on services offered by bundle A plus guava version 19 . I have both guava version 18 and 19 bundles deployed .

When i start bundle B , i face a dependency chain issue for guava libraries , as they are available in two paths ?

Chain - 1

bundle B -> bundle A-> guava concurrency util v18 (dependency of bundle A)

Chain - 2

bundle B -> guava concurrency util v19 (from bundle)

Though i have mentioned the dependency version as guava 19 in bundle B dependency in pom.xml why is that confusing with guava 18 from bundle A dependency . How can i enforce it to ignore guava from bundle A just load version 19 ?

karaf@root()> restart 239
Error executing command: Error restarting bundles:
           Unable to start bundle 239: Uses constraint violation. Unable to resolve resource com.sample.ngemf.fpm.pm.retImpl [com.sample.ngemf.fpm.pm.retImpl [239](R 239.11)] because it is exposed to package 'com.google.common.util.concurrent' from resources com.google.guava [com.google.guava [252](R 252.0)] and com.google.guava [com.google.guava [62](R 62.0)] via two dependency chains.

Chain 1:
  com.sample.ngemf.fpm.pm.retImpl [com.sample.ngemf.fpm.pm.retImpl [239](R 239.11)]
import: (&(osgi.wiring.package=com.google.common.util.concurrent)(version>=19.0.0)(!(version>=20.0.0)))
 |
export: osgi.wiring.package: com.google.common.util.concurrent
  com.google.guava [com.google.guava [252](R 252.0)]

Chain 2:
 com.sample.ngemf.fpm.pm.retImpl [com.sample.ngemf.fpm.pm.retImpl [239](R 239.11)]
    import: (&(osgi.wiring.package=com.sample.sdn.southbound.common.api)(version>=4.1.0)(!(version>=5.0.0)))
 |
export: osgi.wiring.package=com.sample.sdn.southbound.common.api; uses:=com.sample.sdn.southbound.tl1.api
  com.sample.sdn.southbound.common.api [com.sample.sdn.southbound.common.api [187](R 187.0)]
import: (&(osgi.wiring.package=com.sample.sdn.southbound.tl1.api)(version>=4.1.0)(!(version>=5.0.0)))
 |
export: osgi.wiring.package=com.sample.sdn.southbound.tl1.api; uses:=com.google.common.util.concurrent
  com.sample.sdn.southbound.tl1.api [com.sample.sdn.southbound.tl1.api [194](R 194.0)]
import: (&(osgi.wiring.package=com.google.common.util.concurrent)(version>=18.0.0)(!(version>=19.0.0)))
 |
export: osgi.wiring.package: com.google.common.util.concurrent
  com.google.guava [com.google.guava [62](R 62.0)] Unresolved requirements: [[com.sample.ngemf.fpm.pm.retImpl [239](R 239.11)] osgi.wiring.package; (&(osgi.wiring.package=com.sample.sdn.southbound.common.api)(version>=4.1.0)(!(version>=5.0.0)))]

dependency xml in definition in bundle B .

    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>19.0</version>
    </dependency>
    <!-- this is the bundle a dependency which has guava 18 in it -->
    <dependency>
        <groupId>com.sample.sdn.southbound</groupId>
        <artifactId>southbound-common-api</artifactId>
        <version>${package.version}</version>
    </dependency>
user3619698
  • 125
  • 3
  • 13

2 Answers2

0

Add the version of guava to the dependendyManagement section of your pom. Then every other version of guava is replaced by this one.

https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Management

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
0

Try to only install one (the newer) of the guava libraries. As far as I know guava is not very OSGi friendly. So installing it in two versions is very likely to fail.

Christian Schneider
  • 19,420
  • 2
  • 39
  • 64