spring webservice Invalid NamespaceHandler 问题(jaxws)

问题描述 投票:0回答:2

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

无效的 NamespaceHandler 类 [org.apache.cxf.jaxws.spring.NamespaceHandler] 对于命名空间 [http://cxf.apache.org/jaxws]:问题 与处理程序类文件或依赖 班级;嵌套异常是 java.lang.NoClassDefFoundError: org/springframework/beans/factory/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
java web-services spring jax-ws javabeans
2个回答
0
投票

看来您缺少 spring jar,或者您有旧版本的 spring jar。尝试在类路径上获取最新的

spring-beans.jar
。还要确保类路径上没有另一个较旧的此类 jar。


0
投票

所以,我也偶然发现了这个错误,它真的让我很紧张。所以,无需进一步支付

环境:

野蝇20.0.1.最终版

Java 11

目标:

我只想添加 cxf,以便我可以在 applicationContext.xml 中使用 cxf - spring 描述符(特别是 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 LIBRARIES到您的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 ase\org\springframework\spring\main

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

模块.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 ase\org\spring\main

这会造成很多痛苦,因为

如果你看过 wildfly-20.0.1.Final\modules\system\layers ase\org pach

© www.soinside.com 2019 - 2024. All rights reserved.