3 Replies Latest reply on Jun 20, 2009 7:28 PM by oren

    How to install a non-OSGi maven jar as an OSGi bundle in FUSE?

    oren

      Dear All:

       

      I have encountered a specific problem in FUSE ServiceMix ESB 4.1 that is

      seriously hampering my current development. I was wondering if you,

      Scott or another expert could kindly help. I looked around in the forums

      and the maven bnd plugin documentation, but could not find an answer

      anywhere.

       

      I have a non-OSGi legacy maven jar project called core-util, which I

      would like to use as a dependency to my FUSE component maven projects.

      When I tried

       

      osgi/install -s mvn:edu.utah.further.core/core-util

       

      it installed it, but did not start the bundle, as there is no manifest

      in this jar. Consequently, I replaced the core-util pom with the pom

      attached to this email, which should now make it an OSGi bundle.

      However, now I am getting:

       

      ERROR CommandLineExecutionFailed:

      org.apache.geronimo.gshell.command.CommandExce

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

      bundle 160:

      package; (package=javanet.staxutils)

       

      If I add javanet.staxutils to the Export-Package header, it works, but

      then complains on a different package. After repeating the process for

      30 other packages, I was discouraged and tried to use the

      Embed-Dependency header. This forced me to add some dependencies seen at

      the end of the  block, such as quartz, to be able to see

      the package. This is obviously a bad solution and I am not sure how many

      more packages would be required for the ESB to recognize core-util

      including all of its dependencies, so that it could be started and

      recognized by other OSGi bundles. It is also weird that the maven

      project can be compiled and run, i.e. the classpath contains all the

      required dependencies, albeit ServiceMix does not know how to extract

      and use them inside the OSGi environment.

       

      What is the proper procedure to import a non-OSGi maven module in my

      local maven repository into ESB, so that it could be used by OSGi bundles?

       

      A side question: when I type "log/d" at the shell, I often get the

      entire log file from the beginning of the servicemix installation. Is

      there a way to clear the log while ServiceMix is running?wait

       

      Thank you so much in advance,

      Oren

       

      -


      core-util pom.xml -


       

       

        • 1. Re: How to install a non-OSGi maven jar as an OSGi bundle in FUSE?
          joe.luo

          There are several ways to transform/convert a non-OSGI jar into a OSGI bundle.

          1. 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.

          2. 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 above.

          3. you could use maven-bundle-plugin just as in your project to build an OSGI bundle.

           

          However, the bottom line is that you will have to have all dependent packages available as bundles in the container already if you want to start your bundle. It is different from maven where the maven will pull out all the dependencies for you automatically.

           

          As for the log, you could change the log level using log set to minimize the level of logs that printed out.

           

          Hope it helps,

           

          /Joe

          • 2. Re: How to install a non-OSGi maven jar as an OSGi bundle in FUSE?
            oren

            Joe, thank you so much, this helped and solved my problem!!

            Oren

            • 3. Re: How to install a non-OSGi maven jar as an OSGi bundle in FUSE?
              oren

              Joe's answer was excellent!