【问题标题】:spring webservice Invalid NamespaceHandler problem (jaxws)spring webservice Invalid NamespaceHandler 问题(jaxws)
【发布时间】:2011-05-10 04:14:50
【问题描述】:

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

无效的命名空间处理程序类 [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

【问题讨论】:

  • 您好 dds,您能解决这个问题吗?我对嵌入 webapp 的 JBoss 5.1、Spring 3.0.3 和 Mule 有同样的问题。 -Om
  • 嗨,是的,我克服了这个错误,但不幸的是我忘了怎么做:(
  • 通过将 添加到 beans.xml 中?

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


【解决方案1】:

您似乎缺少一个弹簧罐,或者您有一个旧版本的弹簧罐。尝试在类路径上获取最新的spring-beans.jar。还要确保在较旧的类路径上没有另一个这样的 jar。

【讨论】:

  • 我有 com.springframework.beans-3.0.3.RELEASE.jar 就是你说的那个..
  • 好吧,我已经下载并替换了 beans.jar,但错误仍然存​​在。还有其他想法吗?
  • @dds 然后检查是否没有另一个这样的 jar,那是旧的。更好 - 给出你的 lib 文件夹的目录结构
  • @Bozho 我还没有看到任何库重复。我已经编辑了我的问题以显示我的 lib 文件夹。你能看出什么不对吗?
  • 实际上是添加到我的类路径中的外部 jar,我给出的第一个列表是 WEB-INF/lib 文件夹。现在我添加了外部罐子..
【解决方案2】:

所以,我也偶然发现了这个错误,这真的让我很紧张。所以,不用多说

环境:

Wildfly 20.0.1.Final

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>

问题:

但我得到的只是

无效的命名空间处理程序类 [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\base\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\base\org\spring\main

这会造成很多痛苦,因为

如果你看过 wildfly-20.0.1.Final\modules\system\layers\base\org\apache\cxf\impl\main\module.xml,你会看到它对spring有依赖,即

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

但是,我以 org.spring 而不是 org.springframework.spring 的不同名称安装了 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

希望它能帮助其他迷失的灵魂。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-22
    • 2013-08-07
    • 2011-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多