6

I am building a web service with spring. I can build and deploy the project to tomcat but when the server starts up I am getting following error:

Invalid NamespaceHandler class [org.apache.cxf.jaxws.spring.NamespaceHandler] for namespace [http://cxf.apache.org/jaxws]: problem with handler class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/beans/factory/xml/NamespaceHandlerSupport

I have already included the cxf-rt-frontend-jaxws.jar in my classpath.

My bean definition are here:

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

My lib folder contains(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

and my external jars:

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
Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
dds
  • 548
  • 1
  • 6
  • 16
  • Hi dds, Were you able to resolve this issue ? I am having the same problem with JBoss 5.1, Spring 3.0.3 and Mule embedded inside webapp. -Om –  Jun 02 '11 at 14:28
  • hi, yes I overcame this error but unfortunately I forgot how to do it :( – dds Jun 10 '11 at 05:31
  • By adding to your beans.xml ? – redben Mar 15 '12 at 19:42

2 Answers2

0

It appears that either you are missing a spring jar, or you have an older version of it. Try to get the latest spring-beans.jar on the classpath. Also make sure there isn't another such jar on the classpath that's older.

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
  • I have com.springframework.beans-3.0.3.RELEASE.jar is that the one you talking about.. – dds Nov 15 '10 at 11:14
  • well I have download and replace beans.jar but the error remains the same. any other idea? – dds Nov 15 '10 at 11:34
  • @dds then check if there isn't another such jar, that's older. Better - give the directory structure of your lib folder – Bozho Nov 15 '10 at 11:48
  • @Bozho I havent seen any lib duplicate. I have edit my question to show my lib folder. can you see anything wrong? – dds Nov 15 '10 at 12:02
  • actually it is external jar added to my classpath, the first list I gave was the WEB-INF/lib folder. Now I added the external jars.. – dds Nov 15 '10 at 12:20
  • Well, all seems fine. Clean-build, redeploy.. and see again. And make sure the mentionted class is indeed in the beans jar (browse it with rar) – Bozho Nov 15 '10 at 12:24
  • Thanks a lot for your consideration. I have verified the jar and cleaned-rebuild-redeployed smoothly. But when the server starts up the error still sits there... – dds Nov 15 '10 at 12:28
  • anyone got solution on this issue? – Alok Dec 30 '13 at 08:52
0

So, I have stumbled on this error too, and it really got on my nerves. So, without further due

environment:

Wildfly 20.0.1.Final

Java 11

objectives:

I just want to add cxf so that I could use cxf - spring descriptors (in particular jaxws:endpoint) in my applicationContext.xml, i.e

<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>

issue:

but all I get is

Invalid NamespaceHandler class [org.apache.cxf.jaxws.spring.NamespaceHandler] for namespace [http://cxf.apache.org/jaxws]: problem with handler class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/beans/factory/xml/NamespaceHandlerSupport

Solution:

before you begin you SHOULD KNOW that for this stuff to work you have to INSTALL SPRING LIBRARIES to your wildfly application server and so...

The list of spring libraries in my wildfly environment:

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

Installation path is as follows

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

just put spring libraries in this path and add module.txt (that same folder as spring libraries) as follows

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>

======THE END==========

NOTES:

So, if that is so simple why did I fail? WHY?

At first I installed spring libraries in

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

and that cause a lot of misery, because

if you looked at wildfly-20.0.1.Final\modules\system\layers\base\org\apache\cxf\impl\main\module.xml, you would see that it has a dependency on spring, i.e

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

however, I installed spring libraries under different name which was org.spring and not org.springframework.spring, so that was the root of my failure.

my jboss-deployment-structure.xml (in WEB-INF folder) is

<?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>

Related threads (to name a few)

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

Hope it helps other lost souls.

nrd_000002
  • 11
  • 1
  • 2