spring class loader issues in jboss while using spring ws client

spring class loader issues in jboss while using spring ws client  using -'spring,jboss,classpath,classloader,spring-ws'

I have my application running properly in Jboss. To to write spring webservice client, i have generated classes using wsimport. I have written following in configuration

 <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"/>

in jboss?lib i have jboss-jaxws.jar,spring.jar...Now i copied

spring-ws-1.5.0.jar and  saaj-impl-1.3.jar

but i am getting follwoing errors:

The Spring ContextLoaderListener we wrap threw on contextInitialized.
But for our having caught this error, the web application context would not have initialized.
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.IllegalArgumentException: Class [org.apache.xbean.spring.context.v2.XBeanNamespaceHandler] does not implement the NamespaceHandler interface
Caused by:
java.lang.IllegalArgumentException: Class [org.apache.xbean.spring.context.v2.XBeanNamespaceHandler] does not implement the NamespaceHandler interface
    at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.initHandlerMappings(DefaultNamespaceHandlerResolver.java:119)

Please help me to resolve this error. These errors i am getting only after keeping these jars. But these required to run my new code. Please suggest me how to avoid them?

asked Oct 19, 2015 by okesh.badhiye
0 votes
1 view

2 Answers

0 votes

This suggests to me that there are two versions of that JAR in your CLASSPATH - perhaps one on the server itself and another that's deployed as part of your app - and they aren't the same version. The server class loader will find the server version first, before your application class loader runs. If it's an earlier version than required by your app you'll have a problem.

The solution is difficult, because you might not be able to remove the server version without compromising other deployed apps. See if there's a flag in the JBOSS configuration for your application to tell JBOSS to prefer JARs loaded by the application class loader and see if that helps.

http://www.datadisk.co.uk/html_docs/java_app/jboss5/jboss5_deployment.htm http://community.jboss.org/wiki/ClassLoadingConfiguration http://community.jboss.org/wiki/JBossClassLoadingUseCases

answered Oct 19, 2015 by sachin wagh
0 votes

You could create WEB-INF/jboss-web.xml file for your application with next content

" rel="nofollow" target="_blank">http://www.jboss.org/j2ee/dtd/jboss-web_4_2.dtd">


This should prevent classloader from looking for JBoss libs. As a downside you'll have to provide all your 3rd-party jars in a WAR/lib folder.

This works for 4.2 you could lookup something similar for version you currently use.

answered Oct 19, 2015 by kinnari