5 Replies Latest reply on Nov 19, 2012 3:28 AM by thomas.diesler

    Migrating osgi bundles running in Karaf  to JBoss 7 as OSGI container

    mishra900

      Hi,

       

      I am very much new to Jboss 7 as OSGI container .. in fact i am a starter  in Jboss 7 AS .  i wanted to migrate  existing Karaf osgi bundles in to Jboss 7 AS . i mean we have some bundles already running in apache karaf  in production . i wanted to migrate those bundles in to JBoss .  Initailly i have tried to deploy the bundles in the   Standalone   , deployment directory ...

       

      but it is failing to deploy  throwing   Caused by: org.apache.felix.log.LogException: org.jboss.osgi.resolver.XResolverException: Unable to resolve Module [xxxxx ] : missing requirement [Module[xxx]] package ;(&(package=org.apache.felix.service.command)(status=provisional)(version>=0.10.0))] 

       

      Here i have a feeling like , some how  at deployment time , org.apache.felix.service.command package is not getting resolved , may be this is because very much part of  apache felix .  but if i understood correctly  Jboss too has the support for   org.apache.felix.service.command .

       

      Please provide me some tips on this .... ? this is bit urjent for me ..

       

      2ndly ,  assume i am deployed x.jar  in standalone\deployment  folder  and x.jar has dependency on y.jar assume , and y.jar may be using javax.jms inside , by default during deployment  where i need to set this dependecy in standalone.xml  ...

       

      i find inside standalone.xml , we have a section for OSGI   for subsystems ...  so my question here , do i need to keep adding all the dependecy jars under subsystem section inside OSGI  ?

       

      I am really confused here , how to set those dependecy jars in to Jboss 7 as deployment path to avoid the above exception.

       

      any inputs will be highly appricated ... if there is any documents , pdfs in this regard like migrating osgi bundles from Karaf to Jboss , will be a great help ..

        • 1. Re: Migrating osgi bundles running in Karaf  to JBoss 7 as OSGI container
          ulrichromahn

          Hi,

           

           

          I just went through this exact exercise and must say that it was rather painless.

           

           

          We also have a bunch of OSGi bundles build and running in Apache Karaf (we are using 2.2.9). However, we have defined our "application" in a features.xml file which, together with all the bundles gets deployed to a Nexus (Maven) repository. All we have to do in Karaf is actually to specify the URL of that features.xml and do then a features:install <feature name>. It is so convenient and powerful, that I am actually currently investigation how this could be integrated into JBoss AS 7 on top of JBoss OSGi.

           

           

          So, when I tried to migrate my OSGi-based application over to JBoss AS 7 (I am currently doing this with 7.2.0.Alpha1-SNAPSHOT build locally) I had to do the following steps:

          1. Determine all my dependencies by examining my features.xml as well as the standard-2.2.9-features.xml and enterprise-2.2.9-features.xml files to figure out what the exact dependencies were.
          2. Once I had those dependencies determined, I opened the JBOSS_HOME/standalone/configuration/standalone.xml and located the definition of the OSGi Subsystem (<subsystem xmlns="urn:jboss:domain:osgi:1.2" activation="eager">). In that file, I added all my dependencies - preferably in the correct order - as <capabilities>. Here are some examples:
                            <capability name="org.apache.felix:org.apache.felix.scr:1.6.0" startlevel="2"/>
                    <capability name="org.apache.felix:org.apache.felix.eventadmin:1.2.6" startlevel="2"/>
                    <capability name="org.apache.aries:org.apache.aries.util:0.4" startlevel="2"/>
                    <capability name="org.apache.aries.jmx:org.apache.aries.jmx:0.3" startlevel="2"/>
                    <capability name="org.apache.aries.proxy:org.apache.aries.proxy:0.4" startlevel="2"/>
                    <capability name="org.apache.aries.blueprint:org.apache.aries.blueprint:0.4" startlevel="2"/>
          3. Then I started JBoss AS 7 with the OSGi susbsystem starting during boot time (see 'activation="eager"' in the subsystem definition above) looking at the log for possible error messages.

          Once all the errors and missing dependencies have been resolved, my application was up-and-running.

          One important note, however: not all classes in the JRE standard library get exposed to the OSGi system and you will have to configure that. For example, one of our package had a dependency on 'sun.misc'. In order to add those dependencies, you will have to add a specific system property for the OSGi subsystem. The property definition goes inside the standalone.xml inside the <properties> and looks like (for our application):

                          <property name="org.osgi.framework.system.packages.extra">

                      org.apache.log4j;version=1.2,

                      javax.annotation,

                      javax.annotation.processing,

                      sun.misc

                  </property>

          That was basically all I had to do.

          Good luck with your migration.

          • 2. Re: Migrating osgi bundles running in Karaf  to JBoss 7 as OSGI container
            mishra900

            Hi   ulrichromahn,

             

            I am really excited aftre seeing your reply .. It's really been a great help , Thanks for the help and i am really appriciated ..

             

            Need to understand couple of things add to previous ques : Please correct me if i am wrong ..

             

            Section 2 (From your reply ):

             

            New capability in standalone.xml only be loaded  if the bundle   jar files are added to bundles under JBOSS_HOME folder .  i mean we can add a new capabilty based on our required jar's  and before configuring in standalone.xml , those jar's needs to be added in to bundles package ...  correct me if i am wrong here ..

             

            • we  can only add  external jars (apart from sun JVM related jars )  in to the bundles , which are needed for our osgi bundle dependency ..(correct me if i am wrong)

             

             

            Section 3 (From your reply ):

            •    under osgi section inside standalone.xml , we have both capability and properties , so wanted to know does JBoss console displays all the properties configured while starting ...?

             

            One more information wanted to know , my application already running in Fuse has almost 10 different service bundles , hence this all 10 bundles suppose to just moved in to JBOSS_HOME\standalone\deployment folder ..   for deployment ... correct me if i am wrong ...

             

            Assume i have some cxf webservices , hence to migrate the webservices , i need to deploy both model and serviceimpl bundles in to JBOSS_HOME\standalone\deployment folder  .

             

            So i think if i move all model and serviceimpl bundles as per the order , it should work ..

             

            Thanks again for your help ....

            • 3. Re: Migrating osgi bundles running in Karaf  to JBoss 7 as OSGI container
              thomas.diesler

              Folks, have a look at OSGi Roadmap first half 2013

               

              The Karaf integration is at the top of the list and we already made good progress. If you can't wait for the next AS7 release (ETA is not yet known) you could have a look at AS7-5544

              Essentially what you do is to execute a simple maven command in the build-modular dir

               

              build-modular]$ mvn -Dmodular=karaf clean install

              This should give you a preconfigured Karaf runtime

              • 4. Re: Migrating osgi bundles running in Karaf  to JBoss 7 as OSGI container
                mishra900

                Thanks ulrichromahn,

                 

                I am able to configure/deploy the osgi bundles from karaf by adding all the dependency in JBOSS standalone.xml . Now all the bundles are deployed . 

                 

                But they are not actually starting up .  i mean i have  basically some cxf  endpoint webservices are earlier deployed in KARAF , i am looking at similiar behaviour in JBOSS osgi container too.

                 

                i have some WSDL  model jars  and some services jars which are depend on those model jars . it was running in production seamlessly  without any issue .

                 

                but now if i am just moving those model and services bundles in to Jboss OSGI , they are not starting even though in the Jboss server.log is showing they are started .

                 

                i tried to invoke the cxf-endpoint URL to have a look at if the server WSDL is generated on the server, i am seeing 404 error , which means those cxf end points are not getting created .

                 

                Intially i thought may be some how spring auto-waring not happening , but now i can see all spring bundles are also started , but some how , aftre Bundle deployed , Bundle Activator getting called  and after that nothing happening ....

                 

                Any thoughts  ???????????  

                 

                 

                Thanks,

                Biswa

                • 5. Re: Migrating osgi bundles running in Karaf  to JBoss 7 as OSGI container
                  thomas.diesler