1 Reply Latest reply on Sep 25, 2009 9:49 AM by pchandler

    org.osgi.framework.BundleException: Unresolved constraint in bundle

    jokit

      Hi,

      ¨

      I have installed a jar packet to my maven repository (containing a number of java classes)

       

      mvn install:install-file -DgroupId=se.bilprovningen.fordon.services -DartifactId=services -Dfile=C:/Development/BP/ServiceSwitch_dev_mobile/ServiceSwitch/Source/J2EE/ServiceSwitch/APP-INF/lib/FordonClient.jar -Dversion=1.0 -Dpackaging=jar

       

      and then added the jar in my pom.xml file

       

       

       

      I then use a class name Foo from my jar packed

      se.foo.common.util.Foo in my OSGI bundle. The build and installation of the bundle in my FUSE ESB 4.1 works as it should but when a start my osgi bundel a get this error.

       

      ERROR CommandLineExecutionFailed: org.apache.geronimo.gshell.command.CommandExce

      ption: org.osgi.framework.BundleException: Unresolved constraint in bundle 160:

      package; (package=se.foo.common.util)

       

      What is it I?m doing wrong?

        • 1. Re: org.osgi.framework.BundleException: Unresolved constraint in bundle
          pchandler

          Jokit,

           

          First thing to remember is, that in OSGi land resolving compile constraint and run-time constraints are two different things. The issue you are having is a run-time issue. So you can make FordonClient.jar into a bundle, deploy it, and then import it into your bundle (See Option1 & 2). Or you can put FordonClient.jar into the Bundle-ClassPath (Option3).

           

          Most popular Java third party tool already exists as a bundle (search in OSGI Bundle Repository ORB. http://www.osgi.org/Repository/HomePage first!).

           

          Options:

          Introduce/Transform/Convert a non-OSGI jar into an OSGI bundle

           

          1. Bnd - Bundle Tool

          You could use command line tool "bnd", for more information about creating an OSGI bundle from a plain jar, please have a look at their web site http://www.aqute.biz/Code/Bnd. Also, "bnd" can be used in a POM file via the maven-bundle-plugin http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html.

           

          2. Wrap Protocol

          You could use pax-url-wrap and it is already available from the Fuse ESB 4.1. So basically, you could do something like:

          osgi install -s wrap:mvn:com.mycompany/myProject/1.0-SNAPSHOT

          Note, you could used file: instead of mvn: so it allows you to install a jar from your local file system. for instance:

          osgi install -s wrap:file:///C:/temp/myProject.jar

          For more information about pax-url-wrap, please have a look at http://wiki.ops4j.org/display/paxurl/Wrap+Protocol. Basically it uses the "bnd" tool mentioned below. Note:  pax-url-wrap is a third party tool available via default in ServiceMix 4.1 (note: not available by default in Equinox.)

           

          3. Creating a Bundle-ClassPath:

          If the non-OSGi jar is to be private (i.e., not exported to other bundles) to a bundle you are creating then you create a Bundle-Classpath. Think of the Bundle-Classpath as a private/local/embedded classpath just for bundle.

          To create a bundle-classpath without using e  see:

          http://www.aqute.biz/Snippets/BundleClassPath