7 Replies Latest reply on May 29, 2012 6:09 AM by simplex-software

    Can't instal open source bundles on Karaf 2.2.2

    simplex-software

      Greetings,

       

      I need to install an open-source product, named Kettle (an ETL) on Karaf such that to be used in Camel routes. Basically, there are 4-5 jar files that are needed. But since there is not OSGi distribution of it, I need to convert it.

       

      I tried to install the archives in the maven repository and, from there, to install with wrap:mvn. The JARs have been installed as bundles an appeared in active status but their MANIFEST.MF didn't have any import/export statement.

       

      So I used bnd tool to wrap them. This time the MANIFEST.MF had lots of import/export and I thought it was ok so I installed the result in the maven repository and, from there tried to install them in Karaf.

       

      Installing the first bundle, named kettle-core, worked but trying to install the second one, named kettle-engine, raised the following exception:

       

      karaf@root> osgi:install -s mvn:pentaho.kettle/kettle-core/4.2.0-stable

      Bundle ID: 293

      karaf@root> osgi:install -s mvn:pentaho.kettle/kettle-engine/4.2.0-stable

      Error executing command: Unable to resolve module kettle-engine because it exports package 'org.pentaho.di.repository' and is also exposed to it from kettle-core

      via the following dependency chain:

       

        kettle-engine

          import: (package=org.pentaho.di.core.row)

            

       

          export: package=org.pentaho.di.core.row; uses:=org.pentaho.di.repository

          export: package=org.pentaho.di.repository

        kettle-core

       

      Installing the two bundles in the reverse order, like:

       

      karaf@root> osgi:install -s mvn:pentaho.kettle/kettle-engine/4.2.0-stable

      Bundle ID: 295

      karaf@root> osgi:install -s mvn:pentaho.kettle/kettle-core/4.2.0-stable

      Bundle ID: 296

       

      works but will raise an exception when trying to install the third one:

       

      karaf@root> osgi:install -s mvn:pentaho.kettle/kettle-db/4.2.0-stable

      Error executing command: Unable to resolve module kettle-db because it exports package 'org.pentaho.di.core' and is also exposed to it from kettle-core via the fo

      llowing dependency chain:

       

        kettle-db

          import: (package=org.pentaho.di.core.xml)

       

          export: package=org.pentaho.di.core.xml; uses:=org.pentaho.di.core

          export: package=org.pentaho.di.core

        kettle-core

       

      The order of install is obviously important. So how can I determine the right order without having to permute all the combinations ?

       

      Many thanks in advance,

       

      Nicolas

        • 1. Re: Can't instal open source bundles on Karaf 2.2.2
          ffang

          Hi,

           

          This issue isn't about bundle installation order, it's actually from that different bundle try to export same package, this is so called "split package" issue in OSGi container, which should be avoid at all in OSGi. The jar you try to install isn't OSGi  friendly, so some times only add OSGi metadata header isn't enough, the only way I can come up with is that use one shade jar which include all jars have "split package", otherwise you need restructure the package of those bundles, but I don't think it's an easy task nor you have access to these source codes.

           

          Freeman

          • 2. Re: Can't instal open source bundles on Karaf 2.2.2
            simplex-software

            Hi,

             

            Many thanks for the explanations. But how come, in this case, changing the order of the install statements works without raising exceptions ?

             

            For example:

             

            karaf@root> osgi:install -s mvn:pentaho.kettle/kettle-vfs/4.2.0-stable

            Bundle ID: 321

            karaf@root> osgi:install -s mvn:pentaho.kettle/kettle-engine/4.2.0-stable

            Bundle ID: 322

            karaf@root> osgi:install -s mvn:pentaho.kettle/kettle-core/4.2.0-stable

            Bundle ID: 323

             

            In this order it works. The order od the last two bundles is important. Installing kettle-core before kettle-engine raises the exception.

             

            So are the bundles reliable now that, installed in the right order there is no more exception ? Because when trying to refer, for example, kettle-engine from another bundle it raises NoClassDefFoundErroe and ClassNotFoundException for one of the classes in kettle-core and referenced from kettle-engine.

             

            Many thanks in advance,

             

            Nicolas

            • 3. Re: Can't instal open source bundles on Karaf 2.2.2
              ffang

              Hi,

               

              Change bundle installation order can change package resolve from different bundles, so it's possible that the bundle could be resolved and installed,but it isn't reliable during runtime because of the "split package" issue. You shouldn't rely on bundles which have "split package".

               

              Freeman

              • 4. Re: Can't instal open source bundles on Karaf 2.2.2
                simplex-software

                I extracted the content of my three jars in a separated directory and, from it, I created a new jar. Now there are no more split packages as there is only one jar. I wraped this jar with bnd and try to install it but now I ger NPE on the osgi:install command.

                 

                What's missing here ?

                 

                Kind regards,

                 

                Nicolas

                • 5. Re: Can't instal open source bundles on Karaf 2.2.2
                  simplex-software

                  My last comment was not correct as, instead of installing the BAR file created as the bnd output, I trien to install the JAR file which was given to the bnd as an input. The osgi:install works but the same exception

                   

                  Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.pentaho.di.core.logging.LogChannel

                          at org.pentaho.di.core.KettleEnvironment.createDefaultKettleProperties(KettleEnvironment.java:111)[328:k-all:0]

                          at org.pentaho.di.core.KettleEnvironment.createKettleHome(KettleEnvironment.java:102)[328:k-all:0]

                          at org.pentaho.di.core.KettleEnvironment.init(KettleEnvironment.java:51)[328:k-all:0]

                          at org.pentaho.di.core.KettleEnvironment.init(KettleEnvironment.java:43)[328:k-all:0]

                          at com.unic.delimij.integration.kettle_osgi.KettleRouteBuilder$1.process(KettleRouteBuilder.java:27)[332:kettle-osgi:0.0.1.SNAPSHOT]

                          at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)[88:org.apache.camel.camel-core:2.8.0.fuse-03-06]

                   

                  is raised.

                   

                  I really don4t know what to do as now there is no anymore split package and the wrapped jar installs correctly.

                   

                  Many thanks in adavance for any help.

                   

                  Kind regards,

                   

                  Nicolas

                  • 6. Re: Can't instal open source bundles on Karaf 2.2.2
                    ffang

                    Hi,

                     

                    You can

                    1. check if the class org.pentaho.di.core.logging.LogChannel is really there in your big bundle?

                     

                    2. try to add org.pentaho.di.core.logging Import-Package for your camel router bundle.

                     

                    3. setup debug env and step into the code which cause such exception

                     

                    Freeman

                    • 7. Re: Can't instal open source bundles on Karaf 2.2.2
                      simplex-software

                      Hi,

                       

                      1. Checked.

                      2. Added, same result.

                      3. Yeah, this will require more time.

                       

                      The problem is that this requires repackaging such that to get rid of the split packages. And given that this is an open-source project, it means that it will have to be done each time that a new release comes or any one download it.

                       

                      But I understood what the problem is so I'm closing the ticket.

                       

                      Many thanks for your help.

                       

                      Kind regards,

                       

                      Nicolas