「デフォルト」デプロイメントプロファイルを使用してJBoss AS 6.1.0 Finalを使用しています。JBoss AS 6上のセッションBean内のJMSプロデューサが例外をスローする
私はSession BeanからJMSメッセージを送信するのが好きです。私が持っている豆で
<configuration xmlns="urn:hornetq"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
<queue name="queue/DummyMDBean">
<entry name="jms/DummyMDBean"/>
</queue>
</configuration>
:
/サーバー/デフォルト/展開/私の-HornetQは、JMS: は、私は次のように設定し
@Stateless
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class Demo implements DemoRemote, DemoLocal {
...
@Resource(mappedName = "java:/ConnectionFactory")
private static QueueConnectionFactory queueConnectionFactory;
@Resource(mappedName = "/jms/DummyMDBean")
private static Queue queue;
public void example() {
QueueConnection queueConnection = null;
try {
queueConnection = queueConnectionFactory.createQueueConnection();
} catch (JMSException e) {
System.out.println("Exception occurred: " + e.toString());
e.printStackTrace();
}
try {
QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
QueueSender queueSender = queueSession.createSender(queue);
// Send a text message:
TextMessage textMessage = queueSession.createTextMessage();
textMessage.setText("Hello World");
queueSender.send(textMessage);
} catch (JMSException e) {
System.out.println("Exception occurred: " + e.toString());
e.printStackTrace();
} finally {
closeConnection(queueConnection);
}
}
私は次のエラーを取得する:
15:46:05,011 INFO [STDOUT] Exception occurred: javax.jms.JMSException: Failed to create session factory
15:46:05,661 ERROR [STDERR] javax.jms.JMSException: Failed to create session factory
15:46:05,666 ERROR [STDERR] at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:605)
15:46:05,667 ERROR [STDERR] at org.hornetq.jms.client.HornetQConnectionFactory.createQueueConnection(HornetQConnectionFactory.java:131)
15:46:05,668 ERROR [STDERR] at org.hornetq.jms.client.HornetQConnectionFactory.createQueueConnection(HornetQConnectionFactory.java:126)
15:46:05,669 ERROR [STDERR] at com.demo.Demo.example(Demo.java:109)
...
15:46:05,782 ERROR [STDERR] at java.lang.Thread.run(Thread.java:722)
15:46:05,783 ERROR [STDERR] Caused by: java.lang.NullPointerException
15:46:05,784 ERROR [STDERR] at org.hornetq.core.client.impl.ServerLocatorImpl.removeFromConnecting(ServerLocatorImpl.java:682)
15:46:05,784 ERROR [STDERR] at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:751)
15:46:05,785 ERROR [STDERR] at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:601)
15:46:05,785 ERROR [STDERR] ... 180 more
行109は、「queueConnection = queueConnectionFactory.createQueueConnection();」です。
私は上記のxml以外のデフォルトから何も変更しませんでした。 問題の考え方と解決方法を教えてください。
質問には関係ありませんが、最初のtry/catchはあまり意味がないようです。それがスローされたら、(無効な接続で)続行するだけです。 2番目のtry catchは全く同じロギングを行います。最初のキャッチと2回目の試行を削除できます。 –
@Arjan私は知っているが、これはなぜ失敗するのかを調べるためのテストに過ぎない。 – roterl