使用 spring-ws 客户端时 Jboss 中的 Spring 类加载器问题
我的应用程序在 Jboss 中正常运行。为了编写 Spring Webservice 客户端,我使用 wsimport
生成了类。我在配置中写了以下内容
<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>
在 jboss?lib 中,我有 jboss-jaxws.jar,spring.jar
...现在我复制了
spring-ws-1.5.0.jar and saaj-impl-1.3.jar
,但出现以下错误:
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)
请帮助我解决此错误。这些错误是我在保留这些罐子后才出现的。但这些需要运行我的新代码。请建议我如何避免它们?
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"/>
</property>
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这对我来说表明您的 CLASSPATH 中有该 JAR 的两个版本 - 一个可能在服务器本身上,另一个作为您的应用程序的一部分部署 - 并且它们不是同一版本。在应用程序类加载器运行之前,服务器类加载器将首先查找服务器版本。如果它的版本比您的应用程序要求的版本早,您就会遇到问题。
该解决方案很困难,因为您可能无法在不影响其他已部署应用程序的情况下删除服务器版本。查看您的应用程序的 JBOSS 配置中是否有一个标志,告诉 JBOSS 优先选择由应用程序类加载器加载的 JAR,看看这是否有帮助。
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
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
您可以使用下一个内容为您的应用程序创建 WEB-INF/jboss-web.xml 文件,
这应该可以防止类加载器查找 JBoss 库。缺点是您必须在 WAR/lib 文件夹中提供所有第 3 方 jar。
这适用于 4.2,您可以查找与您当前使用的版本类似的内容。
You could create WEB-INF/jboss-web.xml file for your application with next content
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.