java.lang.NoClassDefFoundError: Failed to link... on JBoss 7.1 startup

java.lang.NoClassDefFoundError: Failed to link... on JBoss 7.1 startup

我正在尝试将我的应用程序从 JBoss 6.4 迁移到 7.1。

在启动服务器时我收到了这个警告:

2020-11-16 10:05:46,751 WARN  [org.jboss.modules] (Weld Thread Pool -- 1) Failed to define class com.randomcompany.oracle.spatial.adminws.exception.FaultLoggerListener in Module "deployment.data-stream-ear.ear.data-s
stream-ws.war" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link com/randomcompany/oracle/spatial/adminws/exception/FaultLoggerListener (Module "deployment.data-stream-ear.ear.data-stream-ws.war" from Service Module Loader): org/apache/cxf/logging/FaultListener
        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:423)
        at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
        at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
        at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:77)
        at org.jboss.modules.Module.loadModuleClass(Module.java:713)
        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:412)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:400)
        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
        at org.jboss.as.weld.WeldModuleResourceLoader.classForName(WeldModuleResourceLoader.java:68)
        at org.jboss.weld.bootstrap.AnnotatedTypeLoader.loadClass(AnnotatedTypeLoader.java:65)
        at org.jboss.weld.bootstrap.AnnotatedTypeLoader.loadAnnotatedType(AnnotatedTypeLoader.java:60)
        at org.jboss.weld.bootstrap.FastAnnotatedTypeLoader.loadAnnotatedType(FastAnnotatedTypeLoader.java:104)
        at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:94)
        at org.jboss.weld.bootstrap.ConcurrentBeanDeployer.doWork(ConcurrentBeanDeployer.java:61)
        at org.jboss.weld.bootstrap.ConcurrentBeanDeployer.doWork(ConcurrentBeanDeployer.java:58)
        at org.jboss.weld.executor.IterativeWorkerTaskFactory.call(IterativeWorkerTaskFactory.java:62)
        at org.jboss.weld.executor.IterativeWorkerTaskFactory.call(IterativeWorkerTaskFactory.java:55)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        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)
        at org.jboss.threads.JBossThread.run(JBossThread.java:320)

这是我的 jboss-deployment-structure.xml:

<jboss-deployment-structure>
    <ear-subdeployments-isolated>true</ear-subdeployments-isolated>
    <deployment>
        <dependencies>
            <module name="org.apache.ws.security" />
            <module name="javax.transaction.api" />
            <module name="org.apache.cxf" services="import">
            </module>
        </dependencies>
    </deployment>
    <sub-deployment name="data-stream-ejb.jar">
    </sub-deployment>
    <sub-deployment name="data-stream-ws.war">
        <dependencies>
            <module name="deployment.data-stream-ear.ear.data-stream-ejb.jar" />
        </dependencies>
    </sub-deployment>
    <sub-deployment name="data-stream-gui.war">
    </sub-deployment>
</jboss-deployment-structure>

class 包含在 data-stream-ws.war 中:

package com.randomcompany.oracle.spatial.adminws.exception;

import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.apache.cxf.logging.FaultListener;
import org.apache.cxf.message.Message;

public class FaultLoggerListener implements FaultListener {
    private FaultLoggerInterface faultLogger;
    private String faultLoggerName;

        @Override
    public boolean faultOccurred(Exception exception, String description, Message message) {
        return getFautLogger().logException(exception, description);
    }

    private FaultLoggerInterface getFautLogger() {
        if (this.faultLogger == null) {
            try {
                InitialContext context = new InitialContext();
                this.faultLogger = ((FaultLoggerInterface) context.lookup(this.faultLoggerName));
            } catch (NamingException e) {
                throw new RuntimeException(e);
            }
        }
        return this.faultLogger;
    }

    public void setFaultLoggerName(String faultLoggerName) throws NamingException {
        this.faultLoggerName = faultLoggerName;
    }
}

我尝试将 ear-subdeployments-isolated 设置为 false,但没有成功。

我找到了一个解决方案,仔细检查了我的旧 6.4 standalone.xml; 我已将 cxf 作为全局模块添加到 urn:jboss:domain:ee:4.0 子系统(并将整个子系统的默认配置替换为从旧子系统中获取的配置 - 请注意子系统 1.2 -> 4.0 的不同版本):

<global-modules>
    <module name="org.apache.cxf" slot="main"/>
</global-modules>
<spec-descriptor-property-replacement>true</spec-descriptor-property-replacement>
<jboss-descriptor-property-replacement>true</jboss-descriptor-property-replacement>
<annotation-property-replacement>true</annotation-property-replacement>

应用层没有其他变化,现在部署完成没有问题。