Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ClassNotFoundException while trying to deploy spring ws + saaj webapp on JBoss EAP 6.3

I'm trying to deploy our web application (which works fine in Tomcat 7) on JBoss EAP 6.3 but I'm receiving the following ClassNotFoundException upon deployment

15:49:21,953 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/xxx-webapp]] (ServerService Thread Pool -- 61) JBWEB000287: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageFactory' defined in class path resource [spring/appCtx-xxx-remoting-ws.xml]: Cannot create inner bean 'com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl#6f47288' of type [com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl] while setting bean property 'messageFactory'; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl] for bean with name 'com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl#6f47288' defined in class path resource [spring/appCtx-xxx-remoting-ws.xml]; nested exception is java.lang.ClassNotFoundException: com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl from [Module "deployment.xxx-webapp.war:main" from Service Module Loader]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:282) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:121) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:925) [spring-context-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:472) [spring-context-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:388) [spring-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:293) [spring-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) [spring-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3339) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3777) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
    at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:161) [jboss-as-web-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
    at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:59) [jboss-as-web-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
    at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:94) [jboss-as-web-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_80]
    at java.util.concurrent.FutureTask.run(FutureTask.java:262) [rt.jar:1.7.0_80]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_80]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_80]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_80]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl] for bean with name 'com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl#6f47288' defined in class path resource [spring/appCtx-xxx-remoting-ws.xml]; nested exception is java.lang.ClassNotFoundException: com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl from [Module "deployment.xxx-webapp.war:main" from Service Module Loader]
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1262) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:433) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:271) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    ... 26 more
Caused by: java.lang.ClassNotFoundException: com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl from [Module "deployment.xxx-webapp.war:main" from Service Module Loader]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final-redhat-1]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final-redhat-1]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final-redhat-1]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final-redhat-1]
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final-redhat-1]
    at org.springframework.util.ClassUtils.forName(ClassUtils.java:258) [spring-core-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:417) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1283) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1254) [spring-beans-3.1.4.RELEASE.jar:3.1.4.RELEASE]
    ... 28 more

The SaajSoapMessageFactory is configured to use the SAAJ implementation provided by the Oracle JDK

<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"> 
  <property name="messageFactory">
     <bean class="com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl" />
  </property>
</bean>

We are not bundling any SAAJ implementation in our .war file. Looks like JBoss is somehow preventing that the class is loaded from the JDK.

I played around with various jboss-deployment-structure.xml setups so far but until now to no avail.

like image 827
Kai Avatar asked Feb 09 '23 21:02

Kai


1 Answers

In order for fix this I had to do the following

add the following dependency to my pom

<dependency>
    <groupId>com.sun.xml.messaging.saaj</groupId>
    <artifactId>saaj-impl</artifactId>
    <version>1.3.16</version>
    <scope>provided</scope>
</dependency> 

change the spring bean definition of the messageFactory to the following

<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"> 
  <property name="messageFactory">
     <bean class="com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl" />
  </property>
</bean> 

add a jboss-deployment-structure.xml to the WEB-INF folder of the .war file

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
   <deployment>
      <dependencies>
      <!--    
      we want to use the saaj module provided by JBoss 
      it looks like we can't use the implementation provided by the JDK - JBoss somehow does not seem to allow it
      -->
         <module name="com.sun.xml.messaging.saaj" />
      </dependencies>
   </deployment>
</jboss-deployment-structure>
like image 123
Kai Avatar answered Feb 11 '23 16:02

Kai