无法 link 将 MDB 连接到 Wildfly 10.x 上的入站资源适配器 - 部署失败

Failed to link a MDB to an inbound resource adapter on Wildfly 10.x - deployment failed

我在 github 上编写了一个简单的 tcp 入站资源适配器 (RA) 作为 example project,并成功地将其部署到具有独立完整配置的 wildfly 10.x。消息侦听器 TcpMessageListener 接口位于 RA 中并在 ra.xml 描述符中定义,但我无法将消息驱动 bean (MDB) 连接到它。 RA 的 eis 端按预期工作,我可以使用 telnet 向它发送 connect/send 消息。当我尝试使用 wildfly maven 插件部署 MDB 时,MDB 找不到 TcpMessageListener,我得到了 java.lang.NoClassDefFoundError:

WARN  [org.jboss.modules] (MSC service thread 1-7) Failed to define class de.bitc.ejb.InboundEventHandler in Module "deployment.ra-ear.ear.ra-user-ejb-0.0.1-SNAPSHOT.jar:main" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link de/bitc/ejb/InboundEventHandler (Module "deployment.ra-ear.ear.ra-user-ejb-0.0.1-SNAPSHOT.jar:main" from Service Module Loader): de/bitc/jca/inflow/TcpMessageListener
       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  .
  .
  .
ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC000001: Failed to start service jboss.deployment.subunit."ra-ear.ear"."ra-user-ejb-0.0.1-SNAPSHOT.jar".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."ra-ear.ear"."ra-user-ejb-0.0.1-SNAPSHOT.jar".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of subdeployment "ra-user-ejb-0.0.1-SNAPSHOT.jar" of deployment "ra-ear.ear"
  .
  .
  .
Caused by: java.lang.NoClassDefFoundError: Failed to link de/bitc/ejb/InboundEventHandler (Module "deployment.ra-ear.ear.ra-user-ejb-0.0.1-SNAPSHOT.jar:main" from Service Module Loader): de/bitc/jca/inflow/TcpMessageListener
  .
  .
  .
ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 17) WFLYCTL0013: Operation ("add") failed - address: ([("deployment" => "ra-ear.ear")]) - failure description: {
"WFLYCTL0080: Failed services" => {"jboss.deployment.subunit.\"ra-ear.ear\".\"ra-user-ejb-0.0.1-SNAPSHOT.jar\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.subunit.\"ra-ear.ear\".\"ra-user-ejb-0.0.1-SNAPSHOT.jar\".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of subdeployment \"ra-user-ejb-0.0.1-SNAPSHOT.jar\" of deployment \"ra-ear.ear\"
Caused by: java.lang.NoClassDefFoundError: Failed to link de/bitc/ejb/InboundEventHandler (Module \"deployment.ra-ear.ear.ra-user-ejb-0.0.1-SNAPSHOT.jar:main\" from Service Module Loader): de/bitc/jca/inflow/TcpMessageListener"},
"WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.subunit.\"ra-ear.ear\".\"ra-user-ejb-0.0.1-SNAPSHOT.jar\".POST_MODULE"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined

ejb maven 子模块中的依赖项在 provided 范围内。我跟着部署了 RA redhat guide。我还在 ejb 子模块中切换了资源适配器的 Maven 依赖性,从提供到编译。在这种情况下,我得到了以下错误

[ERROR] Caused by: java.lang.IllegalStateException: WFLYEJB0383: No message listener of type de.bitc.jca.inflow.TcpMessageListener found in resource adapter tcp-eis.rar"},
  "WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.subunit.\"ra-ear.ear\".\"ra-user-ejb-0.0.1-SNAPSHOT.jar \".component.InboundEventHandler.CREATE"],
  "WFLYCTL0180: Services with missing/unavailable dependencies" => undefined}}}

这是 MDB

package de.bitc.ejb;

import java.util.logging.Logger;

import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;

import org.jboss.ejb3.annotation.ResourceAdapter;

import de.bitc.jca.inflow.TcpMessageListener;

@MessageDriven(
    activationConfig = {
            @ActivationConfigProperty(propertyName = "topic",  propertyValue = "test")
        } //, messageListenerInterface = TcpMessageListener.class
        )
@ResourceAdapter(value="tcp-eis.rar")
public class InboundEventHandler implements TcpMessageListener {

    /** The logger */
    private static Logger log = Logger.getLogger(InboundEventHandler.class.getName());

    /**
     * Default constructor.
     */
    public InboundEventHandler() {
        // TODO Auto-generated constructor stub
    }

    /**
     * @see TcpMessageListener#onMessage(String)
     */
    @Override
    public void onMessage(String msg) {
        // TODO Auto-generated method stub
    }
}

这是 TcpListenerInterface

package de.bitc.jca.inflow;

/**
 * TcpMessageListener
 *
 * @version $Revision: $ 
 */
public interface TcpMessageListener {
    /**
     * Receive message
     * 
     * @param msg
     *            String.
     */
    public void onMessage(String msg);
}

这里是jboss_cli

中资源适配器的设置
 /subsystem=resource-adapters/resource-adapter=tcp-eis.rar:read-resource(recursive=true)
{
    outcome => success,
    result => {
        archive => tcp-eis.rar,
        beanvalidationgroups => undefined,
        bootstrap-context => undefined,
        config-properties => undefined,
        module => undefined,
        statistics-enabled => false,
        transaction-support => XATransaction,
        wm-security => false,
        wm-security-default-groups => undefined,
        wm-security-default-principal => undefined,
        wm-security-domain => other,
        wm-security-mapping-groups => undefined,
        wm-security-mapping-required => false,
        wm-security-mapping-users => undefined,
        admin-objects => undefined,
        connection-definitions => undefined
    }
}

我的问题是,部署中是否缺少 MDB 查找资源适配器的步骤。我认为这是通过 @ResourceAdapter 注释完成的?我需要定义一个队列还是什么?关于入站资源适配器的资源非常少,最多的例子是出站资源适配器。提前致谢。

上面链接的 inbound-ra-example 托管在 github 上。我在 github 项目的 README.md 中描述了构建和 运行 它的所有步骤。我想为其他有同样问题查找文档的人托管这些示例。

我解决了 class 加载 NoClassDefFoundError: Failed to link 错误,现在 运行ning 示例回答了许多悬而未决的问题。我把所有的细节都放在了我的 example 中。入站资源适配器 运行s 现在作为 wildfly 10 (WF10) 上 ear 存档中的子部署。我使用 IronJacamar codegenerator 生成了入站资源适配器。我在示例中描述了如何构建和 运行 的所有步骤。

主要的错误是,我没有在 ear 存档中使用 jboss-deployment-structure 描述符,并且没有在 ear 存档中使用对资源适配器 api 的 Maven 依赖性。测试的时候把依赖塞进耳朵里忘记了

<?xml version="1.0" encoding="UTF-8"?>  
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">  
    <ear-subdeployments-isolated>false</ear-subdeployments-isolated>  
    <sub-deployment name="ra-user-ejb.jar">  
        <dependencies>  
            <module name="deployment.ra-ear.ear.tcp-eis.rar"  export="true" />  
        </dependencies>  
    </sub-deployment>  
</jboss-deployment-structure>

这里是我最大的耳朵嵌入式入站 RA 答案,以解决文档泄漏:

  • 不需要ra.xml描述符,RA class中的@Connector注释就足够了。
  • 无需在 WF10 中进行额外配置。没有队列、standallone-full.xml 修改或 jndi 东西。使用 wildfly-maven-plugin 进行简单部署即可。
  • 现在工作的资源适配器在 WF10 中没有显示为资源适配器。这让我很困惑,让我的研究变得非常困难。
  • 不需要 jboss-ejb3.xml 描述符。 @ResourceAdapter(value="ra-ear.ear#tcp-eis.rar") 就足够了。注意,这是一个 jboss 注释,而不是 ee7。所以你找不到任何资源,例如。 websphere 或 tomee.

我将在接下来的几天里将示例资源适配器扩展为一个完整的 ee7 应用程序,并希望这个示例在通过入站资源适配器文档地狱的过程中帮助其他人。