JBoss EAP 7 exclude webservices subsystem gives NoClassDefFoundError: Failed to link EndpointDefinitionParser$SpringEndpointImpl

廉价感情. 提交于 2021-01-03 07:09:03

问题


In Jboss EAP7 I have added cxf maven dependencies in pom.xml and excluded webservices subsystem in jboss-deployment-structure.xml since want to use my own version of cxf defined in pom.xml. But get below exception during server start up-

Caused by: org.springframework.beans.FatalBeanException: 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: Failed to link org/apache/cxf/jaxws/spring/EndpointDefinitionParser$SpringEndpointImpl (Module "deployment.SomeApplication.war:main" from Service Module Loader): Failed to link org/apache/cxf/jaxws/EndpointImpl (Module "deployment.SomeApplication.war:main" from Service Module Loader): javax/xml/ws/Endpoint
at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.resolve(DefaultNamespaceHandlerResolver.java:140)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1406)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1401)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:168)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:138)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:94)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:392)
... 23 more
Caused by: java.lang.NoClassDefFoundError: Failed to link org/apache/cxf/jaxws/spring/EndpointDefinitionParser$SpringEndpointImpl (Module "deployment.SomeApplication.war:main" from Service Module Loader): Failed to link org/apache/cxf/jaxws/EndpointImpl (Module "deployment.SomeApplication.war:main" from Service Module Loader): javax/xml/ws/Endpoint
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
    at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
    at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:78)
    at org.jboss.modules.Module.loadModuleClass(Module.java:605)
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
    at org.apache.cxf.jaxws.spring.EndpointDefinitionParser.<clinit>(EndpointDefinitionParser.java:53)
    at org.apache.cxf.jaxws.spring.NamespaceHandler.init(NamespaceHandler.java:36)
    at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.resolve(DefaultNamespaceHandlerResolver.java:131)
    ... 30 more

pom.xml

<dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>${cxf.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>${cxf.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http-jetty</artifactId>
        <version>${cxf.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxrs</artifactId>
        <version>${cxf.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-rs-client</artifactId>
        <version>${cxf.version}</version>
    </dependency>

jboss-deployment-structure.xml

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
    <dependencies>
        ...
    </dependencies>
    <exclude-subsystems>
        <subsystem name="jaxrs" />
        <subsystem name="webservices" />
        <subsystem name="logging" />
    </exclude-subsystems>
</deployment>

Update: Installed Spring module in JBoss and updated jboss-deployment-structure.xml

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
        <dependencies>
            <!-- Picket link configuration -->
            <module name="org.picketlink" services="import"/>
            <module name="org.springframework.spring" export="true" meta-inf="export"/>
            <module name="org.apache.cxf" export="true" />  
            <module name="org.apache.cxf.impl" export="true" />  
        </dependencies>
        <exclude-subsystems>
            <subsystem name="jaxrs" />
            <subsystem name="webservices" />
            <subsystem name="weld" />
        </exclude-subsystems>
    </deployment>
</jboss-deployment-structure>

Now see below error-

17:04:02,317 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) 

MSC000001: Failed to start service jboss.deployment.unit."abc_code_formatting.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."abc_code_formatting.war".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment "abc_code_formatting.war"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: Failed to link org/apache/cxf/transport/servlet/CXFServlet (Module "org.apache.cxf.impl:main" from local module loader @116af24 (finder: local module finder @e82894 (roots: D:\tools\jboss-eap-7.0.2\modules,D:\tools\jboss-eap-7.0.2\modules\system\layers\base\.overlays\layer-base-jboss-eap-7.0.2.CP,D:\tools\jboss-eap-7.0.2\modules\system\layers\base))): org/springframework/context/ApplicationListener
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
    at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
    at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:78)
    at org.jboss.modules.Module.loadModuleClass(Module.java:605)
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at org.jboss.as.ee.utils.ClassLoadingUtils.loadClass(ClassLoadingUtils.java:21)
    at org.jboss.as.ee.utils.ClassLoadingUtils.loadClass(ClassLoadingUtils.java:14)
    at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:84)
    at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:76)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
    ... 5 more

回答1:


For anyone else who is facing above issue. Here is the solution. Add below dependency in pom/classpath-

<dependency>
  <groupId>javax.xml.ws</groupId>
  <artifactId>jaxws-api</artifactId>
  <version>2.2.9</version>
</dependency>

javax.xml.ws.Endpoint is available in JBoss modules jar. During deployment conflict arises since it's in a different module and you've removed webservices dependency so webapp classloader doesn't see it (I'm assuming classloader look up hierarchy is another issue here since this class is available as part of JDK, ideally JBoss should have honored JDK classpath).




回答2:


jboss-deployment-struture.xml should be as follows

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
        <exclude-subsystems>
            <subsystem name="logging"/>
        </exclude-subsystems>
        <exclusions>
            <module name="org.antlr"/>
            <module name="org.hibernate"/>
        </exclusions>
    </deployment>
</jboss-deployment-structure>



回答3:


Your application is using spring and therefore, are you sure you have installed the spring custom module in EAP 7 and have a dependency included in jboss-deployment-struture.xml file ? so that the required class definition can be found ?

As a reference, you can refer to this link, Spring module in JBoss 7

Also, make sure jboss-deployment-structure.xml has a dependency on this module as below.

<module name="org.apache.cxf.impl" export="true">
                <imports>
                    <include path="META-INF**"/>
                    <include path="META-INF/cxf**"/>
                </imports>
                <exports>
                    <include path="META-INF"/>
                    <include path="META-INF/cxf"/>
                </exports>
            </module>


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!