JBoss EAP 7 exclude webservices 子系统给出 NoClassDefFoundError: Failed to link EndpointDefinitionParser$
Posted
技术标签:
【中文标题】JBoss EAP 7 exclude webservices 子系统给出 NoClassDefFoundError: Failed to link EndpointDefinitionParser$SpringEndpointImpl【英文标题】:JBoss EAP 7 exclude webservices subsystem gives NoClassDefFoundError: Failed to link EndpointDefinitionParser$SpringEndpointImpl 【发布时间】:2017-10-17 10:56:43 【问题描述】:在 Jboss EAP7 中,我在 pom.xml 中添加了 cxf maven 依赖项,并在 jboss-deployment-structure.xml 中排除了 webservices 子系统,因为我想使用我自己在 pom.xml 中定义的 cxf 版本。但是在服务器启动期间出现以下异常-
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>
更新: 在 JBoss 中安装 Spring 模块并更新 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>
现在看下面的错误-
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】:您的应用程序正在使用 spring,因此,您确定您已经在 EAP 7 中安装了 spring 自定义模块并且在 jboss-deployment-struture.xml 文件中包含了一个依赖项?以便找到所需的类定义?
作为参考,你可以参考这个链接, Spring module in JBoss 7
另外,请确保 jboss-deployment-structure.xml 对该模块有如下依赖关系。
<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>
【讨论】:
我在 pom.xml 中包含 spring 依赖项。有什么办法可以避免 jboss 中的配置更改(安装 spring 自定义模块)并指示 jboss 使用类路径中的 spring? 病毒,我已经在 jboss 中安装了 spring 模块并更新了 jboss-deployment-structure.xml 但仍然看到 org/springframework/context/ApplicationListener 的 NoClassDefFoundError。用 stacktrace 更新了帖子。 另外,如果我添加了你提到的 org.apache.cxf 和 org.apache.cxf.impl 的模块依赖项,我不会使用 JBoss CXF jars 吗?【参考方案2】:对于面临上述问题的其他人。这是解决方案。在 pom/classpath 中添加以下依赖项-
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.2.9</version>
</dependency>
javax.xml.ws.Endpoint 在 JBoss 模块 jar 中可用。在部署期间出现冲突,因为它位于不同的模块中,并且您已删除 webservices 依赖项,因此 webapp 类加载器看不到它(我假设类加载器查找层次结构是这里的另一个问题,因为此类可作为 JDK 的一部分,最好是 JBoss应该尊重 JDK 类路径)。
【讨论】:
【参考方案3】:jboss-deployment-struture.xml应该如下
<?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>
【讨论】:
以上是关于JBoss EAP 7 exclude webservices 子系统给出 NoClassDefFoundError: Failed to link EndpointDefinitionParser$的主要内容,如果未能解决你的问题,请参考以下文章
从 JBoss 7 EAP 中排除提供的 jackson 版本
如何为 Undertow / JBoss 7.2 EAP 重写 RewriteValve?
Jboss (6.4 EAP) 到 WebSphere (7.x)
Jboss 4.2.3 迁移到 Jboss 7 EAP、数据源和安全性