spring webservice无效的NamespaceHandler问题(jaxws)

时间:2010-11-15 10:56:58

标签: java web-services spring jax-ws javabeans

我正在用spring构建一个Web服务。我可以构建项目并将其部署到tomcat,但是当服务器启动时,我收到以下错误:

  

NamespaceHandler类无效   [org.apache.cxf.jaxws.spring.NamespaceHandler]   用于命名空间   [http://cxf.apache.org/jaxws]:问题   与处理程序类文件或依赖   类;嵌套异常是   java.lang.NoClassDefFoundError:   组织/ springframework的/豆类/工厂/ XML / NamespaceHandlerSupport

我已经在我的类路径中包含了cxf-rt-frontend-jaxws.jar。

我的bean定义在这里:

 <jaxws:endpoint id="helloWebservice"
  implementor="#com.xxx.impl.HelloWebserviceImpl"
  address="/hellows">
 </jaxws:endpoint>

我的lib文件夹包含(WEB-INF / lib):

antlr-2.7.6.jar
asinus-api.jar
asinus-ri.jar
aspectjrt.jar
aspectjweaver.jar
backport-util-concurrent-3.0.jar
cglib-nodep-2.1_3.jar
commons-beanutils-1.6.jar
commons-codec-1.4.jar
commons-collections-3.2.1.jar
commons-fileupload-1.2.jar
commons-httpclient-3.1.jar
commons-io-1.4.jar
commons-lang-2.4.jar
commons-logging-1.1.1.jar
com.springsource.javax.validation-1.0.0.GA.jar
com.springsource.org.aopalliance-1.0.0.jar
dom4j-1.6.1.jar
ehcache-core-1.7.2.jar
ezmorph-1.0.4.jar
freemarker-2.3.15.jar
hibernate3.jar
hibernate-validator-4.0.2.GA.jar
javassist.jar
jdom.jar
jpa-api-2.0-cr-1.jar
json-lib-2.2.jar
jta-spec1_0_1.jar
lib.txt
log4j-1.2.15.jar
memcached-2.4.2.jar
org.springframework.aop-3.0.2.RELEASE.jar
org.springframework.asm-3.0.2.RELEASE.jar
org.springframework.aspects-3.0.2.RELEASE.jar
org.springframework.beans-3.0.2.RELEASE.jar
org.springframework.context-3.0.2.RELEASE.jar
org.springframework.context.support-3.0.2.RELEASE.jar
org.springframework.core-3.0.2.RELEASE.jar
org.springframework.expression-3.0.2.RELEASE.jar
org.springframework.jdbc-3.0.2.RELEASE.jar
org.springframework.orm-3.0.2.RELEASE.jar
org.springframework.test-3.0.2.RELEASE.jar
org.springframework.transaction-3.0.2.RELEASE.jar
org.springframework.web-3.0.2.RELEASE.jar
owasp.jar
quartz-1.7.3.jar
rome-1.0.jar
slf4j-api-1.5.6.jar
slf4j-log4j12-1.5.6.jar
spring-modules-cache.jar

和我的外部罐子:

cxf-2.2.5.jar
geronimo-activation_1.1_spec-1.0.2.jar
geronimo-jaxws_2.1_spec-1.0.jar
geronimo-ws-metadata_2.0_spec-1.1.2.jar
jaxb-api-2.1.jar
jaxb-impl-2.1.12.jar
neethi-2.0.4.jar
saaj-api-1.3.jar
saaj-impl-1.3.2.jar
stax-api-1.0.1.jar
wsdl4j-1.6.2.jar
wss4j-1.5.8.jar
wstx-asl-3.2.9.jar
xml-resolver-1.2.jar
XmlSchema-1.4.5.jar
xmlsec-1.4.3.jar
WEB-INF/lib/cxf-rt-frontend-jaxws.jar

2 个答案:

答案 0 :(得分:0)

看来您要么缺少一个弹簧罐,要么就是它的旧版本。尝试在类路径上获取最新的spring-beans.jar。还要确保类路径中没有另一个这样的jar更旧。

答案 1 :(得分:0)

所以,我也偶然发现了这个错误,它真的让我感到不安。因此,无需进一步

环境:

Wildfly 20.0.1.Final

Java 11

目标:

我只想添加cxf,以便可以在我的applicationContext.xml中使用cxf-弹簧描述符(特别是jaxws:endpoint)

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
    <!-- one or more jaxws:endpoint POJO declarations -->
    <jaxws:endpoint id="POJOEndpoint" address="/test" implementor="com.test.myRandomPojoEndpoint">
        <jaxws:invoker>
            <bean class="org.jboss.wsf.stack.cxf.InvokerJSE"/>
        </jaxws:invoker>
    </jaxws:endpoint>
</beans>

问题:

但我得到的只是

无效的NamespaceHandler类 命名空间的[org.apache.cxf.jaxws.spring.NamespaceHandler] [http://cxf.apache.org/jaxws]:处理程序类文件或 依赖阶级嵌套的异常是java.lang.NoClassDefFoundError: org / springframework / beans / factory / xml / NamespaceHandlerSupport

解决方案:

开始之前应该知道,要使此功能正常工作,您必须安装SPRING LIBRRIES 到您的wildfly应用服务器,如此...

我的wildfly环境中的spring库列表:

spring-aop-5.2.9.RELEASE.jar
spring-beans-5.2.9.RELEASE.jar
spring-context-5.2.9.RELEASE.jar
spring-core-5.2.9.RELEASE.jar
spring-expression-5.2.9.RELEASE.jar
spring-jcl-5.2.9.RELEASE.jar
spring-tx-5.2.9.RELEASE.jar
spring-web-5.2.9.RELEASE.jar

安装路径如下

wildfly-20.0.1.Final \ modules \ system \ layers \ base \ org \ springframework \ spring \ main

只需将spring库放在此路径中,并按如下所示添加module.txt(与spring库相同的文件夹)

module.txt

<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ JBoss, Home of Professional Open Source.
  ~ Copyright 2010, Red Hat, Inc., and individual contributors
  ~ as indicated by the @author tags. See the copyright.txt file in the
  ~ distribution for a full listing of individual contributors.
  ~
  ~ This is free software; you can redistribute it and/or modify it
  ~ under the terms of the GNU Lesser General Public License as
  ~ published by the Free Software Foundation; either version 2.1 of
  ~ the License, or (at your option) any later version.
  ~
  ~ This software is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  ~ Lesser General Public License for more details.
  ~
  ~ You should have received a copy of the GNU Lesser General Public
  ~ License along with this software; if not, write to the Free
  ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  -->
<module name="org.springframework.spring" xmlns="urn:jboss:module:1.6">

    <resources>
        <resource-root path="spring-aop-5.2.9.RELEASE.jar"/>
        <resource-root path="spring-beans-5.2.9.RELEASE.jar"/>
        <resource-root path="spring-context-5.2.9.RELEASE.jar"/>
        <resource-root path="spring-core-5.2.9.RELEASE.jar"/>
        <resource-root path="spring-expression-5.2.9.RELEASE.jar"/>
        <resource-root path="spring-jcl-5.2.9.RELEASE.jar"/>
        <resource-root path="spring-tx-5.2.9.RELEASE.jar"/>
        <resource-root path="spring-web-5.2.9.RELEASE.jar"/>
    </resources>
    <dependencies>
        <module name="org.reactivestreams" />
            <module name="org.apache.commons.logging" />
            <module name="javaee.api"/>
            <module name="javax.api" export="true" />
            <module name="javax.servlet.api" />
            <module name="org.jboss.vfs" />
    </dependencies>
</module>

======结束=========

注意:

那么,如果这么简单,为什么我失败了?为什么?

首先,我在其中安装了spring库。

wildfly-20.0.1.Final \ modules \ system \ layers \ base \ org \ spring \ main

那会带来很多痛苦,因为

如果您看过 wildfly-20.0.1.Final \ modules \ system \ layers \ base \ org \ apache \ cxf \ impl \ main \ module.xml ,您会发现它对spring有依赖性,即< / p>

    <module name="org.springframework.spring" optional="true">
        <imports>
            <include path="META-INF"/>
        </imports>
    </module>

但是,我以不同的名称安装了Spring库,它们的名称为 org.spring 而不是 org.springframework.spring ,所以这是我失败的根源。

我的jboss-deployment-structure.xml(在WEB-INF文件夹中)是

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
        <dependencies>
            <module name="org.springframework.spring">
                <imports>
                    <include path="META-INF"/>
                </imports>
                <exports>
                    <include path="META-INF"/>
                </exports>
            </module>
            <module name="org.apache.cxf">
                <imports>
                    <include path="META-INF/cxf"/>
                    <include path="META-INF"/>
                </imports>
                <exports>
                    <include path="META-INF/cxf"/>
                    <include path="META-INF"/>
                </exports>
            </module>
            <module name="org.apache.cxf.impl">
                <imports>
                    <include path="META-INF/cxf"/>
                    <include path="META-INF"/>
                </imports>
                <exports>
                    <include path="META-INF/cxf"/>
                    <include path="META-INF"/>
                </exports>
            </module>
        </dependencies>
    </deployment>
</jboss-deployment-structure>

相关线程(仅举几例)

https://stackoverflow.com/questions/44033999/jboss-eap-7-exclude-webservices-subsystem-gives-noclassdeffounderror-failed-to

http://www.mastertheboss.com/javaee/jboss-web-services/using-spring-cxf-descriptors-in-wildfly

http://www.mastertheboss.com/javaee/jboss-web-services/using-spring-cxf-descriptors-in-wildfly

https://cxf.apache.org/docs/embedding-cxf-inside-spring.html

希望它可以帮助其他迷路的人。

相关问题