我在 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 中描述了构建和运行它的所有步骤。我想为其他有相同问题的人提供这些示例以查找文档。