14 Replies Latest reply on Mar 25, 2008 9:35 AM by mike.ramnarine

    Creating OSGI modules for ServiceMix 4

    seumas.soltysik

      Now that ServiceMix 4.0 is an OSGI container at its core what do I need to do to migrate a module that I have written based upon CXF? More specifically if I have an FTP transport I have written for CXF which is now packaged up in a plain old jar, what steps so I have to take to bundle it in order to install it into ServiceMix4.0? Is there a maven plugin which will enable me to easily package this transport? Will ServiceMix make it easy to specify all the cxf dependencies?

       

      Also, how does a user deploy a CXF endpoint using the new ServiceMix4.0/OSGI framework? Is the expectation that they will use Spring-OSGI to deploy an endpoint?

        • 1. Re: Creating OSGI modules for ServiceMix 4
          gnodet_gnodet
          seumas.soltysik wrote:

          Now that ServiceMix 4.0 is an OSGI container at its core what do I need to do to migrate a module that I have written based upon CXF? More specifically if I have an FTP transport I have written for CXF which is now packaged up in a plain old jar, what steps so I have to take to bundle it in order to install it into ServiceMix4.0? Is there a maven plugin which will enable me to easily package this transport? Will ServiceMix make it easy to specify all the cxf dependencies?

           

          CXF will be provided in an OSGi bundle, but due to some internal reasons, not as separate bundles.  I'm not sure how adding a new transport will be done yet.  There is a need to override the extension discovery mechanism in CXF to cope with OSGi, and this has not been written yet.  That done, just deploying a bundle with a new transport should be sufficient.

           

          Also, how does a user deploy a CXF endpoint using the new ServiceMix4.0/OSGI framework? Is the expectation that they will use Spring-OSGI to deploy an endpoint?

           

          There will be several ways, one of them being spring osgi and configuring the CXF endpoints as usual.  Other will include using JBI components or packaging your service a la EJB3

          • 2. Re: Creating OSGI modules for ServiceMix 4
            mike.ramnarine

            Thanks.  Can you or anyone provide any more background on this?  In general, we're trying to figure out how to migrate and expose some existing components to SMX4.  Are there any tools or notes available to help with this?

             

            And regarding the comments above, would the internal reasons for going with one CXF bundle be a matter of priority, a recommendation on granularity, or are there technical issues?   In the long run, would it make sense to provide a separate bundle for each component, for example for each transport?  And, any idea when an initial CXF bundle might be done?

            • 3. Re: Creating OSGI modules for ServiceMix 4
              gnodet_gnodet
              mike.ramnarine wrote:

              Thanks.  Can you or anyone provide any more background on this?  In general, we're trying to figure out how to migrate and expose some existing components to SMX4.  Are there any tools or notes available to help with this?

               

              And regarding the comments above, would the internal reasons for going with one CXF bundle be a matter of priority, a recommendation on granularity, or are there technical issues?   In the long run, would it make sense to provide a separate bundle for each component, for example for each transport?  And, any idea when an initial CXF bundle might be done?

               

              The reason for having a single bundle is that OSGi does not support well packages shared by multiple bundles.  But CXF packages are sometimes defined by multiple jars, so using several bundles would cause problems.   It may be fixed, but this would require some incompatible changes and may be done in a major version. 

              That said, it would be nice if new CXF transport could be discovered dynamically by deploying new bundles.  This could be done, but would require some work to detect new bundles and see if it contains CXF extensions.  Another way (I'm don't recall how the CXF Api work) would be that the bundle expose a TransportFactory in the OSGi registry so that CXF can discover them dynamically in the OSGi registry when needed.  With Camel, we've tried another way:   camel can leverage any of its own transport (and there's a lot) and wrap it using CXF:

               

                 soap:xxx
              

               

              where xxx is any camel transport uri, such as:

               

                 soap:jms:queue:MyQueue
              

               

               

              Anyway, for the CXF bundle, there is one available at

                 http://people.apache.org/repo/m2-snapshot-repository/org/apache/servicemix/bundles/org.apache.servicemix.bundles.cxf-2.0.3/1.0-SNAPSHOT/
              

               

              Edited by: gnodet on Jan 30, 2008 3:41 AM

               

              Edited by: gnodet on Jan 30, 2008 3:41 AM

              • 4. Re: Creating OSGI modules for ServiceMix 4
                mike.ramnarine

                Has anyone tried to use the CXF bundle?

                 

                I've tried loading up the cxf bundle directly into OSGi (eclipse equinox), but there are quite a few missing imports.

                 

                osgi> install file:C:\.m2\org\apache\servicemix\bundles\org.apache.servicemix.bundles.cxf-2.0.4\1.0-SNAPSHOT\org.apache.

                servicemix.bundles.cxf-2.0.4-1.0-SNAPSHOT.jar

                Bundle id is 35

                 

                osgi> diag 35

                file:C:\.m2\org\apache\servicemix\bundles\org.apache.servicemix.bundles.cxf-2.0.4\1.0-SNAPSHOT\org.apache.servicemix.bun

                dles.cxf-2.0.4-1.0-SNAPSHOT.jar

                  Missing imported package com.ibm.wsdl.extensions.schema_0.0.0.

                  Missing imported package com.ibm.wsdl.extensions.soap_0.0.0.

                  Missing imported package com.sun.codemodel_0.0.0.

                ... 293 more including

                  Missing imported package org.springframework.beans_2.5.0.

                 

                 

                I tried loading springframework.beans from my .m2 cache but don't seem to have a version 2.5.0, only 2.5.1, and I don't see a 2.5.0 on the web.  I tried loading C:\.m2\org\springframework\spring\2.5.1\spring-2.5.1.jar, but that doesn't resolve the related missing imports.

                 

                Any suggestions on finding missing packages?  Is there a better way to do this?

                • 5. Re: Creating OSGI modules for ServiceMix 4
                  gnodet_gnodet

                  Another way would be to grab a snashot of servicemix 4 full distro (not the kernel only) at

                    http://people.apache.org/repo/m2-snapshot-repository/org/apache/servicemix/features/apache-servicemix/1.0-SNAPSHOT/

                   

                  It should include all the needed bundles.

                  • 6. Re: Creating OSGI modules for ServiceMix 4
                    mike.ramnarine

                    Thanks Guillaume.  I found the CXF bundle and a few others in the features repo a little over a week ago, and bundled the others that I needed on my own.  But then I ran into a problem where an endpoint couldn't be resolved - I think this is where we need a change in CXF to do OSGi based location rather than using the classpath/classloader.

                    • 7. Re: Creating OSGI modules for ServiceMix 4
                      gnodet_gnodet

                      Yeah, I think CXF will need to be updated somehow to cope with the OSGi classloading mechanism, but I'm not a CXF expert, so I'm not sure how this should / can be done.  I think there is a real need to be able to discover dynamically new transports / extensions.  The main problem is that the CXF architecture has not been designed to allow dynamic changes afaik, so if there is a new transport available, the only real solution is to recreate the bus and everything.  I may be wrong here, so any insight is welcome.

                       

                      Anyway, what I've done in the distribution I've pointed previously is to integrate EJB3 by embedding OpenEjb and CXF, which allows to deploy an EJB3 jar (with web services) and have them deployed on the OSGi http service and handled by CXF.  Everything is not finished, but I had it working for a simple web service / statless session bean.

                      • 8. Re: Creating OSGI modules for ServiceMix 4
                        mike.ramnarine

                        Guillaume, or anyone who has details:

                         

                        Is SMX4 going to supply the 3rd party jars that are needed to install and start the CXF bundle (currently org.apache.servicemix.bundles.cxf-2.0.4-1.0-SNAPSHOT.jar)? 

                        If not can you at least provide pointers to OSGi bundles for all of the dependencies?

                         

                        When we try to install and start just the CXF bundle in SMX4, built with today's source, we still get:

                        ERROR BundleException: Unresolved package in bundle 27: package; (package=javax.xml.bind.attachment)

                         

                        I tried installing and starting the jaxb bundle from:

                        install "file:C:/Dev/Servicemix-4.0/features/trunk/camel/bundles/jaxb-api/target/org.apache.servicemix.bundles.jaxb-api-2.0-1.0-SNAPSHOT.jar"

                        But then another package is needed: javax.mail

                        In the past I cobbled together all the dependencies myself, but we need something more official.

                         

                        Is there a big 3rd party bundle available to satisfy the CXF bundle, from FUSE or anywhere? 

                        If not, what do you do to get the CXF bundle fully resolved and able to start?

                         

                        Edited by: mike.ramnarine on Mar 4, 2008 11:36 PM

                        • 9. Re: Creating OSGI modules for ServiceMix 4
                          gnodet_gnodet

                           

                          Well, it already does.  See below.

                           

                           

                          When we try to install and start just the CXF bundle in SMX4, built with today's source, we still get:

                          ERROR BundleException: Unresolved package in bundle 27: package; (package=javax.xml.bind.attachment)

                           

                          I tried installing and starting the jaxb bundle from:

                          install "file:C:/Dev/Servicemix-4.0/features/trunk/camel/bundles/jaxb-api/target/org.apache.servicemix.bundles.jaxb-api-2.0-1.0-SNAPSHOT.jar"

                          But then another package is needed: javax.mail

                          In the past I cobbled together all the dependencies myself, but we need something more official.

                           

                          Is there a big 3rd party bundle available to satisfy the CXF bundle, from FUSE or anywhere? 

                          If not, what do you do to get the CXF bundle fully resolved and able to start?

                           

                          Just use the full distribution instead of trying to use a single bundle from it.

                          When you compile the following svn tree:

                             http://svn.apache.org/repos/asf/servicemix/smx4/nmr/trunk/

                          you'll find a distribution in the following dir:

                             assembly/target

                          This is the ServiceMix Kernel + ServiceMix NMR + a number of other things (transaction manager, activemq, cxf, ejb3 ...),

                          so just unzip and run

                             bin/servicemix

                           

                          You will also find nearly all the needed bundles in the system folder of this distribution.

                           

                          mike.ramnarine wrote:

                           

                          Edited by: mike.ramnarine on Mar 4, 2008 11:36 PM

                          Guillaume, or anyone who has details:

                           

                          Is SMX4 going to supply the 3rd party jars that are needed to install and start the CXF bundle (currently org.apache.servicemix.bundles.cxf-2.0.4-1.0-SNAPSHOT.jar)? 

                          If not can you at least provide pointers to OSGi bundles for all of the dependencies?

                           

                          • 10. Re: Creating OSGI modules for ServiceMix 4
                            mike.ramnarine

                            Unfortunately the wiki has formatted away some of your reply (I think leading spaces cause a problem). 

                            Which svn tree to compile?  And where is the distribution you mentioned?

                            Also what does the mvn command look like to do this build (is it just mvn with no arguments or options)?

                            • 11. Re: Creating OSGI modules for ServiceMix 4
                              gnodet_gnodet

                              Damn wiki !

                               

                              Just use the full distribution instead of trying to use a single bundle from it.

                              When you compile the following svn tree: http://svn.apache.org/repos/asf/servicemix/smx4/nmr/trunk/

                              Just run: and you'll find a distribution in the following dir .

                              This is the ServiceMix Kernel + ServiceMix NMR + a number of other things (transaction manager, activemq, cxf, ejb3 ...),

                              so just unzip and run .

                               

                              You will also find nearly all the needed bundles in the system folder of this distribution.

                              • 12. Re: Creating OSGI modules for ServiceMix 4
                                gnodet_gnodet
                                • 13. Re: Creating OSGI modules for ServiceMix 4
                                  mike.ramnarine

                                  I just updated and rebuilt SMX4 and was able to start SMX on Windows using features\trunk\assembly\target\apache-servicemix-1.0-SNAPSHOT.zip, and I see lots of bundles loaded automatically, including several for CXF.

                                   

                                  Thanks!!!

                                   

                                  The CXF related bundles install, but don't start; is this a concern? 

                                  It looks like some 3rd party dependencies are still unresolved, do you plan to take care of this?

                                   

                                  MRAMNARI@MRAMNARINE810:></![CDATA[> list
                                  START LEVEL 100
                                     ID   State         Level  Name
                                  ...
                                  [  36] [Installed  ] [   50] openejb-cxf (3.0.0.beta-2)
                                  ...
                                  [  43] [Installed  ] [   50] ServiceMix OSGI Common Bundles: cxf (1.0.0.SNAPSHOT)
                                  ...
                                  [  79] [Installed  ] [   50] ServiceMix CXF Transport for NMR (1.0.0.SNAPSHOT)
                                  [  85] [Installed  ] [   50] ServiceMix CXF Binding for NMR (1.0.0.SNAPSHOT)
                                  MRAMNARI@MRAMNARINE810:/> start 85
                                  ERROR BundleException: Unresolved package in bundle 43: package; (package=org.apache.xml.resolver.helpers)
                                  MRAMNARI@MRAMNARINE810:/> start 36
                                  ERROR BundleException: Unresolved package in bundle 43: package; (package=org.apache.xml.resolver.helpers)
                                  MRAMNARI@MRAMNARINE810:/> start 79
                                  ERROR BundleException: Unresolved package in bundle 43: package; (package=org.apache.xml.resolver.helpers)
                                  MRAMNARI@MRAMNARINE810:/>
                                  

                                   

                                  • 14. Re: Creating OSGI modules for ServiceMix 4
                                    mike.ramnarine

                                    Following up on this thread, some fixes went into SMX4 (features) in mid-March which allowed the CXF bundles to install and start. And Guillaume provided an example that showed that the CXF bundle could be used to setup a simple service with a SOAP endpoint in SMX4. There is a more current discussion about the CXF class discovery mechanism at: