我真的需要帮助。
我有一个简单的Java客户端(由Eclipse运行,在容器外部)。 我在Localhost上运行Wildfly 9。 我在Wildfly上部署了一个简单的MDB作为耳包。
客户端对" jms / RemoteConnectionFactory"进行JNDI查找。 它得到并使用HornetQJMSConnectionFactory。 它将一个ObjectMessage发送到我的MDB监听的队列。
MDB的onMessage(消息消息)显示它收到消息。 而msg是HornetQObjectMessage的一个实例。 但是当我尝试将msg转换为HornetQObjectMessage时,我可以检索Object,它会失败。
对于HornetQObjectMessage,核心错误似乎是NoClassDefFoundError,因此我的应用程序无法访问HornetQ API(我认为是org.hornetq模块)。
注意:Cast位于try catch块中,但是我的catch块没有输出Wildfly日志?
我已粘贴下面的MDB代码。
我的module.xml
并从Wildfly日志中提取相关行。 显然消息到了。请参阅" XXXXXXXXXX"字首。 然后失败!
耳朵没有战争模块。
注意:我添加@ApplicationScoped只是因为建议解决我发布的早期问题。这是我现在的问题吗?
请帮忙。
MDB代码:
@MessageDriven(
activationConfig ={
@ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
@ActivationConfigProperty(propertyName="maxSession",propertyValue="1"),
@ActivationConfigProperty(propertyName="destination", propertyValue="jms/goSendToServerQueue")
})
public class GoMsgBean implements MessageListener {
@ApplicationScoped
@Inject
@JMSConnectionFactory ("java:jboss/DefaultJMSConnectionFactory")
private JMSContext jmsCtx;
@Resource(name = "java:jboss/exported/jms/goSendToClientQueue")
private Queue sendToClientQueue;
public GoMsgBean () {
}
@PostConstruct
public void myInit () {
System.out.println("XXXXXXXXXX Post Construct - GoMsgBean");
}
@PreDestroy
public void myDestroy () {
System.out.println("XXXXXXXXXX Post Destroy - GoMsgBean");
}
public void onMessage(Message msg) {
System.out.println("XXXXXXXXXX Greetings From GoMsgBean.onMessage()");
System.out.println("XXXXXXXXXX Message Type is " + msg.getClass().getSimpleName());
try {
HornetQObjectMessage oMsg = (HornetQObjectMessage) msg;
System.out.println("XXXXXXXXXX Successfully Cast msg to HornetQObjectMessage");
System.out.println("XXXXXXXXXX Object Type is " + oMsg.getObject().getClass().getSimpleName());
} catch (ClassCastException e) {
System.out.println("XXXXXXXXXX ClassCastException");
} catch (JMSException e) {
System.out.println("XXXXXXXXXX JMSException ");
} catch (Exception e) {
System.out.println("XXXXXXXXXX " + e.getClass().getSimpleName()");
}
}
}
MODULE.XML
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.acmemq">
<dependencies>
<!-- we depend on org.hornetq module since we will send messages to -->
<!-- the HornetQ server embedded in the local WildFly instance -->
<module name="org.hornetq" />
</dependencies>
</module>
WILDFLY LOG(WARN和ERROR的摘录)
Calling "D:\Bulletproof\bpWildFly\bin\standalone.conf.bat"
Setting JAVA property to "C:\Program Files\Java\jdk1.8.0_05\bin\java"
===============================================================================
JBoss Bootstrap Environment
JBOSS_HOME: "D:\Bulletproof\bpWildFly"
JAVA: "C:\Program Files\Java\jdk1.8.0_05\bin\java"
JAVA_OPTS: "-Dprogram.name=standalone.bat -Xms64M -Xmx512M -XX:MaxPermSize=256M -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jbos
s.byteman"
===============================================================================
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256M; support was removed in 8.0
...
13:59:09,204 WARN [org.jboss.as.txn] (ServerService Thread Pool -- 60) WFLYTX0013: Node identifier property is set to the default value. Please make
sure it is unique.
13:59:09,880 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
13:59:09,994 WARN [org.jboss.as.messaging] (MSC service thread 1-6) WFLYMSG0001: AIO wasn't located on this platform, it will fall back to using pure
Java NIO.
13:59:10,010 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-1) WFLYDS0013: Started FileSystemDeploymentService for directory D:\
Bulletproof\bpWildFly\standalone\deployments
...
13:59:13,067 WARN [org.jboss.weld.Validator] (MSC service thread 1-8) WELD-001440: Scope type @javax.enterprise.context.ApplicationScoped() used on i
njection point [BackedAnnotatedField] @ApplicationScoped @Inject @JMSConnectionFactory private org.america3.gotest.server.messaging.GoMsgBean.jmsCtx
13:59:13,076 WARN [org.jboss.weld.Validator] (MSC service thread 1-8) WELD-001440: Scope type @javax.enterprise.context.ApplicationScoped() used on i
njection point [BackedAnnotatedField] @ApplicationScoped @Inject @JMSConnectionFactory private org.america3.gotest.server.messaging.GoMsgBean.jmsCtx
13:59:13,316 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 9.0.2.Final (WildFly Core 1.0.2.Final) started in 6207ms - Starte
d 480 of 676 services (264 services are lazy, passive or on-demand)
#START UP COMPLETED#
#MESSAGE RECEIVED#
14:01:04,983 INFO [stdout] (Thread-3 (HornetQ-client-global-threads-1527152166)) XXXXXXXXXX Post Construct - GoMsgBean
14:01:04,985 INFO [stdout] (Thread-3 (HornetQ-client-global-threads-1527152166)) XXXXXXXXXX Greetings From GoMsgBean.onMessage()
14:01:04,986 INFO [stdout] (Thread-3 (HornetQ-client-global-threads-1527152166)) XXXXXXXXXX Message Type is HornetQObjectMessage
14:01:04,987 INFO [stdout] (Thread-3 (HornetQ-client-global-threads-1527152166)) XXXXXXXXXX Post Destroy - GoMsgBean
14:01:04,989 ERROR [org.jboss.as.ejb3.invocation] (Thread-3 (HornetQ-client-global-threads-1527152166)) WFLYEJB0034: EJB Invocation failed on component GoMsgBean for method public void org.america3.gotest.server.messaging.GoMsgBean.onMessage(javax.jms.Message):javax.ejb.EJBTransactionRolledbackException: WFLYEJB0457: Unexpected Error
...
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: org/hornetq/jms/client/HornetQObjectMessage
...
... 52 more
Caused by: java.lang.ClassNotFoundException: org.hornetq.jms.client.HornetQObjectMessage from [Module "deployment.GoTest.ear.GoTest.jar:main" from Service Module Loader]
...
... 80 more
14:01:05,002 ERROR [org.hornetq.ra] (Thread-3 (HornetQ-client-global-threads-1527152166)) HQ154004: Failed to deliver message: javax.ejb.EJBTransactio
nRolledbackException: WFLYEJB0457: Unexpected Error
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:153)
...
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: org/hornetq/jms/client/HornetQObjectMessage
...
... 52 more
Caused by: java.lang.ClassNotFoundException: org.hornetq.jms.client.HornetQObjectMessage from [Module "deployment.GoTest.ear.GoTest.jar:main" from Service Module Loader]
...
... 80 more