javaosgikarafapache-commons-lang3

how to avoid karaf load the default resolve bundle


I use the karaf to run an OSGI bundle which use a built-in commons-lang3.5.jar.

The problem is when I run this bundle, the karaf will auto load another commons-lang3.1.jar. I am not sure when it be load. But it take my bundle crash.

Are there any ways to uninstall the karaf default built-in bundle?


Solution

  • Nope, don't "uninstall" the default built-in bundle cause it is used by others. Make sure your own bundle does a clean import for the commons lang bundle.

    a bnd instruction would look like:

    import-package:
       org.apache.commons.lang;version="[3.5,4.0)", \
       *
    

    this way you make sure you import only commons lang if there is a better version available then the one you already have included yourself.

    Hint, don't embed dependencies, but make sure you depend on re-usable dependencies. With such import packages you can make sure you depend on a specific version.