2 Replies Latest reply on Jul 29, 2009 9:43 AM by Peter Chandler

    ServiceMix and Spring and Runtime.

    Peter Chandler Master

      I have a simple application that uses Spring at runtime.  I am trying to port it to servicemix.  I compiled it with Spring version 2.5.6 and put the Spring Jar in my bundle-classpath.  However, I am getting a LinkageError.


      Questions: Anyone have experience with using Spring at runtime within (called from) a OSGi Bundle? How do I synchronize versions of the compiled bundle with the servicemix runtime? Can I just import the required Spring packages from ServiceMix into my bundle? What version of Spring should I use for FUSE 4.x?


      Compiled with:




      org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from file /export/home/machine/1/user/programs/fuse-esb-; nested exception is java.lang.LinkageError: loader constraint violation: when resolving method "javax.xml.parsers.DocumentBuilder.setEntityResolver(Lorg/xml/sax/EntityResolver;)V" the class loader (instance of org/apache/felix/framework/searchpolicy/ModuleImpl$ModuleClassLoader) of the current class, org/springframework/beans/factory/xml/DefaultDocumentLoader, and the class loader (instance of org/apache/felix/framework/searchpolicy/ModuleImpl$ModuleClassLoader) for resolved class, javax/xml/parsers/DocumentBuilder, have different Class objects for the type org/xml/sax/EntityResolver used in the signature

              at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:420)

              at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)

              at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)

              at org.springframework.beans.factory.xml.XmlBeanFactory.(XmlBeanFactory.java:61)

        • 1. Re: ServiceMix and Spring and Runtime.
          Joe Luo Novice

          The latest Fuse ESB has Spring 2.5.6 pre-installed:


          smx@root:/> osgi/list |grep Spring

             ID   State         Spring     Level  Name

          Spring Context (2.5.6)

          Spring Core (2.5.6)

          Spring Beans (2.5.6)

          Spring AOP (2.5.6)

          Apache ServiceMix Kernel :: Spring Deployer (1.1.0.fuse)

          Spring Transaction (2.5.6)

          Apache ServiceMix NMR Spring (1.1.0.fuse)

          Spring JMS (2.5.6)

          Spring Context Support (2.5.6)


          which means your application bundle can use any packages from those Spring bundles by simply "Import-Package" of required ones. Please have a look at ESB 4 examples for "maven-bundle-plugin" usage.

          • 2. Re: ServiceMix and Spring and Runtime.
            Peter Chandler Master