1

我在 github 上编写了一个简单的 tcp 入站资源适配器 (RA) 作为示例项目,并将其成功部署到具有独立完整配置的 Wildfly 10.x。消息侦听TcpMessageListener器接口位于 RA 中并在 ra.xml 描述符中定义,但我无法将消息驱动 bean (MDB) 连接到它。RA 的 eis 端按预期工作,我可以使用 telnet 向其连接/发送消息。当我尝试使用 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范围内。我跟着redhat指南的RA部署。我还在 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 中描述了构建和运行它的所有步骤。我想为其他有相同问题的人提供这些示例以查找文档。

4

1 回答 1

0

我解决了类加载NoClassDefFoundError: Failed to link错误,现在运行的示例回答了许多未解决的问题。我把所有细节都放在了我的例子中。入站资源适配器现在作为 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 描述符是不需要的,@ConnectorRA 类中的注解就足够了。
  • 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 应用程序,并希望这个示例可以帮助其他人通过入站资源适配器文档地狱。

于 2017-10-17T06:22:21.253 回答