10 Replies Latest reply on Dec 16, 2010 11:24 AM by jkallen63@yahoo.com

    CamelNamespaceHandler does not implement Spring NamespaceHandler interface

    jkallen63@yahoo.com

      Folks, I have a Fusesource project going on which is making use of Servicemix 4.3.0-fuse-02.00.  The project has multiple modules with Maven pom files.  I have been tasked with deploying many of the modules together as a single bundle using the maven.bundle.plugin configured with embedded transitive dependencies:

       

                  <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency> 

                  <Embed-Transitive>true</Embed-Transitive>

       

      From my perspective, this goes against the grain of Servicemix in that one would normally want small, reusable bundles.  However, from what I read this should be possible.

       

      I have two questions:

      1)  Is it OK to use embedded dependencies - particularly transitive?  If so, are there any watchouts?

       

      2)  I can't get this bundle to startup in Servicemix.  Why?  Builds, Junits, and even mvn camel:run all work perfectly using this massive bundle.  I can import the bundle fine into servicemix (without the "-s" option).  When I go to start the bundle or use the import with the "-s" option, I get this error:

       

      15:32:26,627 | DEBUG | ExtenderThread-7 | OsgiBundleXmlApplicationContext  | gatedExecutionApplicationContext  304 | 62 - org.springframework.context - 3.0.3.RELEASE | Pre refresh error

      org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from URL bundle://179.0:0/META-INF/spring/bundle-context.xml; nested exception is org.springframework.beans.FatalBeanException: Class for namespace http://camel.apache.org/schema/spring does not implement the interface

           at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)[60:org.springframework.beans:3.0.3.RELEASE]

      ...

       

      I've searched the web and found that this kind of things seems to be most often associated with a mismatch between Spring and Camel versions.  I get the error when I've run the osgi container as felix and equinox with no variation in results.  My bundle uses Spring 3.0.3 while Camel is 2.5.0.  I've looked in the jar file produced and confirmed that the many dependencies embedded in it only include the expected versions of Spring and Camel.  The bundle/jar seems to be internally consistent.

       

      Debug messages from the Servicemix log show that Servicemix is aware of multiple versions of Spring and Camel.  The Loaded schema mappings message shows multiple versions, anyway.  The Loaded NamespaceHandler mappings message shows both problematic handlers being loaded - just before the error strikes. 

       

      Any ideas on how to make a bundle which uses embedded resources deploy into Servicemix without this error would be appreciated as would recommendations on using embedded dependencies.

       

      Thank you very much for your time!

       

      John Allen

       

       

       

      Additional Info:

       

      bundle-context.xml:

       

        • 1. Re: CamelNamespaceHandler does not implement Spring NamespaceHandler interface
          davsclaus

          What do you mean by fusesource project? Do you mean you have Fuse consultants on site or you have a fuse subscription?

          • 2. Re: CamelNamespaceHandler does not implement Spring NamespaceHandler interface
            jkallen63@yahoo.com

            We have a fusesource subscription, and yes there are fusesource consultants working on related projects though not mine and I am not such a consultant.  If it actually matters, I used the term thinking only that I was using fusesource software - servicemix and camel.  As I developed a great fondness for servicemix and camel and even took a training class a few weeks back from one of your instructors (web seminar), I thought perhaps you folks would have some suggestions for the problem I was experiencing.  I had registered on your message board when my project decided to use servicemix at the recommendation of others here, so it seemed a good idea.  I'm not so sure now.

             

            So now I have to ask a third question:  What does the definition of fusesource matter to the answering of my questions?

             

            John Allen

            • 3. Re: CamelNamespaceHandler does not implement Spring NamespaceHandler interface
              davsclaus

              This is a public community where any registered user can post. So anybody can help out if they can.

               

              On the other hand being a subscriber you have a private "channel" where you can ask for help. 

               

              As a subscriber you will of course get priorities over non subscribers in terms of time and effort by the fusesource staff.

               

              Do you have multiple versions of Spring bundles installed? eg Spring 3.0.3 and 3.0.4 etc.?

              • 4. Re: CamelNamespaceHandler does not implement Spring NamespaceHandler interface
                jkallen63@yahoo.com

                I understand.  It was naive of me to not realize.

                 

                No, only Spring 3.0.3 is installed.   A listing of the servicemix Spring modules confirms this on the servicemix side (though there is an XBean listed as Spring (3.7)).

                 

                karaf@root> osgi:list | grep "Spring"

                   ID   State         Blueprint      Spring    Level  Name

                Apache Karaf :: Spring Deployer (2.0.0.fuse-01-00)

                Spring Core (3.0.3.RELEASE)

                Spring ASM (3.0.3.RELEASE)

                Spring Aspects (3.0.3.RELEASE)

                Spring Expression Language (3.0.3.RELEASE)

                Spring Beans (3.0.3.RELEASE)

                Spring AOP (3.0.3.RELEASE)

                Spring Context (3.0.3.RELEASE)

                Spring Context Support (3.0.3.RELEASE)

                Spring Transaction (3.0.3.RELEASE)

                Spring JMS (3.0.3.RELEASE)

                Apache XBean :: Spring (3.7)

                 

                 

                Looking in the jar file that was generated as a bundle using the Embed-Dependancy tag and which is failing to start, I see all jar files for Spring except for one are at version 3.0.3.  spring-aop-3.0.5 RELEASE.jar is, of course, at version 3.0.5.  This differs from the 3.0.3 version contained in servicemix.

                 

                Hmmm, I didn't catch that discrepancy before and am not sure if it matters, but I'll see if I can't resolve it.  And in the case of embedded dependencies, I'm not sure which wins out - the embedded jars or the servicemix jars.  I figured the embedded jars as I forced the bundle manifest via the project Maven pom file to not import any packages as my requirements were to use only what got embedded into the bundle rather than what was in servicemix (right or wrong).

                 

                         

                 

                 

                Thank you for your assistance.

                 

                John Allen

                 

                  • EDIT **

                I discovered that the spring-aop-3.0.5 RELEASE.jar was the version pulled into my bundle's embedded jars by Camel 2.5.0.  I switched my project over to using Camel 2.4.0-fuse-01-00 which set the dependency on spring-aop to 3.0.3 which was my intention as it matches what is in servicemix, but the bundle still fails to start.  Might as well jump back to Camel 2.5 and keep using the latest Camel in my project.

                 

                Edited by: jkallen63@yahoo.com on Dec 14, 2010 8:01 PM

                • 5. Re: CamelNamespaceHandler does not implement Spring NamespaceHandler interface
                  davsclaus

                  There is a Fuse MR 2.5.0 release out, which is based on Apache Camel 2.5 with additional bug fixes, and it supports CXF 2.3.0 as well (there is also a Fuse SF 2.3 release).

                   

                  http://repo.fusesource.com/nexus/content/groups/public/org/apache/camel/apache-camel/2.5.0-fuse-00-00/

                  • 6. Re: CamelNamespaceHandler does not implement Spring NamespaceHandler interface
                    davsclaus

                    And version 2.5 of Fuse MR is now listed on the download page as well

                     

                    http://fusesource.com/downloads/

                    • 7. Re: CamelNamespaceHandler does not implement Spring NamespaceHandler interface
                      jkallen63@yahoo.com

                      That's good to know.  I'll switch my project over to it then.

                       

                      My project team, with the help of information from your group, was able to convince our management to go with a more standard approach to using fusesource.  We will now be using multiple, smaller, more focused bundles rather than a single one with all dependencies embedded - something for which I am very much relieved.  We can now take full advantage of the excellent features provided with the Fusesource product!!!

                       

                      I would be curious about when <Embed-Dependency> is recommended for use, if at all.  But my project is no longer using it so it is just an educational item for me. 

                       

                      Thanks again.

                       

                      John Allen

                      • 8. Re: CamelNamespaceHandler does not implement Spring NamespaceHandler interface
                        j3rem1e

                        In my opinion, it's not recommended to embed a lot of dependencies, especially shared librairies.

                         

                        In your case, your bundle has his own "org.springframework.beans.factory.xml.NamespaceHandler" .class, and Spring DM import this interface from the Spring Beans bundle

                         

                        Even if your NamespaceHandler is compatible with the spring beans one (binary compatible, same .class), the Class instance belongs to two different ClassLoader and are not considered as the same class.

                         

                        You can Export and Re-Import all your package as a workaround, but it's an ugly hack.

                        • 9. Re: CamelNamespaceHandler does not implement Spring NamespaceHandler interface
                          davsclaus
                          j3rem1e wrote:

                           

                          > In my opinion, it's not recommended to embed a lot of dependencies, especially shared librairies.

                           

                           

                          Yeah. I think you should only embed small libraries which are not shared (or frameworks such as Spring, XML parsers, Camel, CXF etc.). And when those libraries are not OSGi compliant.

                          • 10. Re: CamelNamespaceHandler does not implement Spring NamespaceHandler interface
                            jkallen63@yahoo.com

                            That makes sense.  Its good to know that it is there for those special cases, and I will keep those conditions in mind going forward.

                             

                            Thanks again, you guys!