4 Replies Latest reply on Jan 11, 2017 2:54 PM by mchitti-1

    Fuse fabric deployment throwing Error loading class [org.springframework.ws.soap.saaj.SaajSoapMessageFactory]

    mchitti-1

      Hi

       

       

      I am using spring-ws component to consume a SOAP service and trying to deploy it to Fuse using fabric, but getting Error loading class [org.springframework.ws.soap.saaj.SaajSoapMessageFactory],

       

      Jboss Version : jboss-fuse-6.3.0.redhat-187

       

      Below is the exception stack trace.

       

      org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.ws.soap.saaj.SaajSoapMessageFactory] for bean with name 'messageFactory' defined in URL [bundle://967.0:0/META-INF/spring/camel-context.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org.springframework.ws.soap.saaj.SaajSoapMessageFactory not found from bundle [Empty Camel Spring Example [TestRDCDemo] (TestRDCDemo)]

        at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1281)[203:org.apache.servicemix.bundles.spring-beans:3.2.16.RELEASE_1]

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:575)[203:org.apache.servicemix.bundles.spring-beans:3.2.16.RELEASE_1]

        at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1347)[203:org.apache.servicemix.bundles.spring-beans:3.2.16.RELEASE_1]

        at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:913)[203:org.apache.servicemix.bundles.spring-beans:3.2.16.RELEASE_1]

        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:617)[203:org.apache.servicemix.bundles.spring-beans:3.2.16.RELEASE_1]

        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:938)[205:org.apache.servicemix.bundles.spring-context:3.2.16.RELEASE_1]

        at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)[209:org.springframework.osgi.core:1.2.1]

        at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)[209:org.springframework.osgi.core:1.2.1]

        at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)[209:org.springframework.osgi.core:1.2.1]

        at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)[209:org.springframework.osgi.core:1.2.1]

        at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)[210:org.springframework.osgi.extender:1.2.1]

        at java.lang.Thread.run(Thread.java:745)[:1.8.0_101]

      Caused by: java.lang.NoClassDefFoundError: org.springframework.ws.soap.saaj.SaajSoapMessageFactory not found from bundle [Empty Camel Spring Example [TestRDCDemo] (TestRDCDemo)]

        at org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:112)

        at org.springframework.osgi.util.BundleDelegatingClassLoader.loadClass(BundleDelegatingClassLoader.java:156)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_101]

        at org.springframework.util.ClassUtils.forName(ClassUtils.java:265)[201:org.apache.servicemix.bundles.spring-core:3.2.16.RELEASE_1]

        at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:419)[203:org.apache.servicemix.bundles.spring-beans:3.2.16.RELEASE_1]

        at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1299)[203:org.apache.servicemix.bundles.spring-beans:3.2.16.RELEASE_1]

        at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1270)[203:org.apache.servicemix.bundles.spring-beans:3.2.16.RELEASE_1]

        ... 11 more

      Caused by: java.lang.NoClassDefFoundError: org/springframework/beans/factory/InitializingBean

        at java.lang.ClassLoader.defineClass1(Native Method)[:1.8.0_101]

        at java.lang.ClassLoader.defineClass(ClassLoader.java:763)[:1.8.0_101]

        at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.findClass(BundleWiringImpl.java:2318)

        at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1524)

        at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:77)

        at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1993)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_101]

        at org.apache.felix.framework.BundleWiringImpl.getClassByDelegation(BundleWiringImpl.java:1397)

        at org.apache.felix.framework.BundleWiringImpl.searchImports(BundleWiringImpl.java:1577)

        at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1507)

        at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:77)

        at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1993)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_101]

        at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1853)

        at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:958)

        at org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:99)

        ... 17 more

      Caused by: java.lang.ClassNotFoundException: org.springframework.beans.factory.InitializingBean not found by org.apache.servicemix.bundles.spring-ws-core [979]

        at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1556)[org.apache.felix.framework-4.4.1.jar:]

        at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:77)[org.apache.felix.framework-4.4.1.jar:]

        at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1993)[org.apache.felix.framework-4.4.1.jar:]

        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_101]

        ... 33 more

       

      camel-context.xml :

       

      <bean class="com.test.rdc.process.TestRDCProcessor" id="testRDCProcess"/>

      <bean

              class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory" id="messageFactory">

              <property name="messageFactory">

                  <bean class="com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl"/>

              </property>

          </bean>

          <bean

              class="org.springframework.ws.transport.http.HttpComponentsMessageSender" id="messageSender1">

              <property name="credentials">

                  <bean class="org.apache.http.auth.UsernamePasswordCredentials">

                      <constructor-arg index="0" value="${user}"/>

                      <constructor-arg index="1" value="${password}"/>

                  </bean>

              </property>

          </bean>

          <bean class="org.springframework.ws.client.core.WebServiceTemplate"

              id="baseCamelMarshallerWSTemplate" scope="prototype">

              <constructor-arg ref="messageFactory"/>

              <property name="messageSender">

                  <ref bean="messageSender1"/>

              </property>

              <property name="checkConnectionForError" value="true"/>

              <property name="transformerFactoryClass" value="com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"/>

          </bean>

         

          <cxf:rsServer address="http://localhost:8080/services/gpp/transactions/rdc"

              id="transactionRDC" serviceClass="com.test.rdc.restService.TransactionRDCService"/>

             

          <camelContext id="_camelContext1" xmlns="http://camel.apache.org/schema/spring">

               <route id="transactionRDC1">

                  <from id="_to2" uri="cxfrs:bean:transactionRDC"/>

                  <bean id="_bean3" method="createReq" ref="testRDCProcess"/>

                  <to id="_to15" uri="spring-ws:http://{{host}}:{{port}}/test/TestServiceImpl?webServiceTemplate=#baseCamelMarshallerWSTemplate"/>

                  <log id="_log11" message="after calling soap service ${body}"/>

               </route>

          </camelContext>

       

       

      pom dependencies :

       

      <dependencies>

            <dependency>

              <groupId>org.jboss.fuse.bom</groupId>

              <artifactId>jboss-fuse-parent</artifactId>

              <version>${jboss.fuse.bom.version}</version>

              <type>pom</type>

              <scope>import</scope>

            </dependency>

          </dependencies>

        </dependencyManagement>

        <dependencies>

          <dependency>

            <groupId>org.apache.camel</groupId>

            <artifactId>camel-core</artifactId>

            <version>2.17.3</version>

          </dependency>

          <dependency>

            <groupId>org.apache.camel</groupId>

            <artifactId>camel-spring</artifactId>

            <version>2.17.3</version>

          </dependency>

          <dependency>

            <groupId>org.slf4j</groupId>

            <artifactId>slf4j-api</artifactId>

          </dependency>

          <dependency>

            <groupId>org.slf4j</groupId>

            <artifactId>slf4j-log4j12</artifactId>

          </dependency>

          <dependency>

            <groupId>log4j</groupId>

            <artifactId>log4j</artifactId>

          </dependency>

          <dependency>

            <groupId>org.apache.camel</groupId>

            <artifactId>camel-test-spring</artifactId>

            <version>2.17.3</version>

          </dependency>

          <dependency>

            <groupId>org.apache.camel</groupId>

            <artifactId>camel-cxf</artifactId>

            <version>2.17.3</version>

          </dependency>

          <dependency>

           <groupId>com.sun.xml.messaging.saaj</groupId>

           <artifactId>saaj-impl</artifactId>

           <version>1.3.23</version>

        </dependency>

          <dependency>

            <groupId>org.apache.camel</groupId>

            <artifactId>camel-spring-ws</artifactId>

            <version>2.17.3</version>

          </dependency>

        <dependency>

           <groupId>org.apache.httpcomponents</groupId>

           <artifactId>httpclient</artifactId>

        </dependency> 

        <dependency>

            <groupId>org.apache.cxf</groupId>

            <artifactId>cxf-rt-frontend-jaxrs</artifactId>

            <version>3.1.5.redhat-630187</version>

          </dependency>

          <dependency>

            <groupId>org.apache.cxf</groupId>

            <artifactId>cxf-rt-bindings-xml</artifactId>

            <version>3.1.5.redhat-630187</version>

          </dependency>

          <dependency>

            <groupId>org.apache.cxf</groupId>

            <artifactId>cxf-rt-frontend-simple</artifactId>

            <version>3.1.5.redhat-630187</version>

          </dependency>

          <dependency>

            <groupId>org.apache.camel</groupId>

            <artifactId>camel-cxf-transport</artifactId>

            <version>2.17.3</version>

          </dependency>

          <dependency>

            <groupId>org.apache.cxf</groupId>

            <artifactId>cxf-rt-bindings-soap</artifactId>

            <version>3.1.5.redhat-630187</version>

          </dependency>

          <dependency>

            <groupId>org.apache.cxf</groupId>

            <artifactId>cxf-rt-wsdl</artifactId>

            <version>3.1.5.redhat-630187</version>

          </dependency>

          <dependency>

            <groupId>org.apache.cxf</groupId>

            <artifactId>cxf-rt-transports-http-jetty</artifactId>

            <version>3.1.6</version>

          </dependency>

          <dependency>

            <groupId>org.apache.camel</groupId>

            <artifactId>camel-http</artifactId>

            <version>2.17.3</version>

          </dependency>

        </dependencies>

       

      Can some please please give some inputs on this issue.

       

      Note: When I am trying to run using local camel context from JBoss Developer Studio the same code, it works fine. I am able to get the SOAP response.

       

      Thanks,

      Madhu

        • 1. Re: Fuse fabric deployment throwing Error loading class [org.springframework.ws.soap.saaj.SaajSoapMessageFactory]
          vrlgohel

          You need to install,

          JBossFuse:karaf@root> features:install camel-spring-ws .

           

          Also, check by deploying the jar, org.apache.servicemix.bundles.spring-ws-core-2.2.4.RELEASE_1.jar in the /deploy.

          You can enable 'dynamic-import' <bundle-id> as well.

          • 2. Re: Fuse fabric deployment throwing Error loading class [org.springframework.ws.soap.saaj.SaajSoapMessageFactory]
            mchitti-1

            Thanks Viral for responding.

             

            I tried features:install, deploying the spring-ws-core-2.2.4.RELEASE_1.jar in the /deploy and 'dynamic-import'. Still the same issue, no change in the stack trace.

             

            I tried using org.springframework.ws.soap.axiom.AxiomSoapMessageFactory instead of org.springframework.ws.soap.saaj.SaajSoapMessageFactory, no use. It is throwing the below exception

             

            ["org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.ws.soap.axiom.AxiomSoapMessageFactory] for bean with name 'messageFactory' defined in URL [bundle://362.1:0/META-INF/spring/camel-context.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError:

             

            We are in a critical situation and any help on this is really appreciated.

             

            Thanks,

            Madhu

             

            • 3. Re: Fuse fabric deployment throwing Error loading class [org.springframework.ws.soap.saaj.SaajSoapMessageFactory]
              alele

              Please avoid to use /deploy folder in any serious deployment. This functionality is provided for development work as well as for particular troublesome software components which can not be deployed any other way easily. Files placed into the /deploy folder are assumed not to be particularly OSGI-compliant. Consequently the container substantially relaxes all the package isolation rules that serve to prevent bundles being used in ways for which they were not designed. For example, all Java packages are automatically exported to all other bundles.

               

              In general, sometimes you can get bundles to work by placing them into the deploy folder, but most of the times can't with osgi:install or features:install because one of the below reason:

               

              1. Either your bundles do not specify the correct imports and/or exports

              2. Or your bundles have dependencies that have not themselves been enabled using osgi:install, etc.

               

              Both these problems can be awkward to resolve unless you're very familiar with working with the OSGi model. However, I would suggest that working around them using the deploy folder is not the best way to move on. To some extent we can advise on problems related to missing dependencies or bad import/export configuration.

               

              Every OSGi bundle should explicitly state the Java packages it imports (uses) and exports (provides) and, if necessary, which exact versions it requires. If you look inside the bundle JAR, at the MANIFEST.MF file, you should see entries of the form "Import-Package" and "Export-Package." You'll see this information also if you use the "headers" command at the Fuse prompt -- missing imports are typically shown in red.

               

              If a bundle specifies an import, there must be a matching export in some other bundle that has already been loaded, and of the right version, if a version is listed. If there isn't a matching export for the import, the importing module simply won't start. However, it's not uncommon to see imports marked as "optional," and these won't prevent the module starting if the corresponding package is not exported. However, if the module turns out to need that package after all, it will just fail at runtime instead.

               

              Developers who use Maven to build their bundles typically rely on Maven's built-in support for building the import and export information. It's pretty clever, but not perfect, and it's quite common to have to tweak the imports by hand. IDE tools also deal with this stuff but, again, not always perfectly. There's no substitute for understanding the OSGi module wiring policy in detail. I hope this will help.

              • 4. Re: Fuse fabric deployment throwing Error loading class [org.springframework.ws.soap.saaj.SaajSoapMessageFactory]
                mchitti-1

                Thanks for the detailed information Avadhut, I checked MANIFEST.MF file for imports and exports, everything looks fine, I don't know what I am missing excatly.

                 

                For now instead of spring-ws component I am using cxf to consume the soap service and able to deploy it to fuse using fabric.

                 

                I appreciate if anyone can help figuring out the solution with the spring-ws component issue.

                 

                Thanks