本文介绍了使用 spring-ws 客户端时 Jboss 中的 Spring 类加载器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序在 Jboss 中正常运行.为了编写 spring webservice 客户端,我使用 wsimport 生成了类.我在配置中写了以下内容

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>

在 jboss?lib 我有 jboss-jaxws.jar,spring.jar...现在我复制了

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-INF/jboss-web.xml 文件,其中包含下一个内容

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

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web PUBLIC
    "-//JBoss//DTD Web Application 4.2//EN"
    "http://www.jboss.org/j2ee/dtd/jboss-web_4_2.dtd">
<jboss-web>
    <class-loading java2ClassLoadingCompliance="false">
        <loader-repository>
                   myapp:loader=anyUniqueName
            <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
        </loader-repository>
    </class-loading>
</jboss-web>

这应该可以防止类加载器寻找 JBoss 库.不利的一面是,您必须在 WAR/lib 文件夹中提供所有 3rd-party jar.

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.

这适用于 4.2,您可以查找与您当前使用的版本类似的内容.

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

这篇关于使用 spring-ws 客户端时 Jboss 中的 Spring 类加载器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-12 20:03