我正在尝试在 JBOSS 5.1 中创建一个 hello world MDB,以了解如何将我们的消息传递应用程序放入 JBOSS 5.1 消息传递中。简单的地狱世界 MDB 给了我一个有线问题。MDB 部署良好,启动 JBOSS 5.1 AS 没有问题。但是,当我尝试从同样运行 JBOSS 51 的客户端发送消息时,会引发以下异常,
09:03:24,790 ERROR [STDERR] java.lang.NullPointerException
09:03:24,790 ERROR [STDERR] at org.jboss.jms.client.container.FailoverValveInterceptor.invoke(FailoverValveInterceptor.java:87)
09:03:24,790 ERROR [STDERR] at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:86)
09:03:24,791 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
09:03:24,791 ERROR [STDERR] at org.jboss.jms.client.container.ClosedInterceptor.invoke(ClosedInterceptor.java:170)
09:03:24,791 ERROR [STDERR] at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:86)
09:03:24,791 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
09:03:24,791 ERROR [STDERR] at org.jboss.jms.client.delegate.ClientConnectionDelegate.createSessionDelegate(ClientConnectionDelegate.java)
09:03:24,791 ERROR [STDERR] at org.jboss.jms.client.JBossConnection.createSessionInternal(JBossConnection.java:269)
09:03:24,791 ERROR [STDERR] at org.jboss.jms.client.JBossConnection.createQueueSession(JBossConnection.java:165)
但是,当我尝试从独立的 JAVA 程序连接时,消息传递工作正常。我不知道我现在应该做什么。以下是配置,
ejb-jar.xml:
<message-driven>
<ejb-name>HelloWorldMDB</ejb-name>
<ejb-class>com.yodlee.messaging.mdbs.HelloWorldMDB</ejb-class>
<transaction-type>Container</transaction-type>
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
<subscription-durability>Durable</subscription-durability></message-driven-destination>
<resource-ref>
<res-ref-name>HelloWorldMDB</res-ref-name>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Container</res-auth></resource-ref>
</message-driven>
jboss.xml:
<message-driven>
<ejb-name>HelloWorldMDB</ejb-name>
<destination-jndi-name>queue/HelloWorldQueue</destination-jndi-name>
<mdb-user>mqm</mdb-user>
<mdb-passwd>mqm</mdb-passwd>
<resource-ref>
<res-ref-name>HelloWorldMDB</res-ref-name>
<jndi-name>MDBDLQCF</jndi-name>
</resource-ref>
</message-driven>
我在servelt和独立程序中使用它的客户端代码与下面完全相同,
Properties env = new Properties();
String queueName = "queue/HelloWorldQueue";
String CFname = "ConnectionFactory";
env.put(Context.PROVIDER_URL, "jnp://....:1099");
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
env
.put(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
try {
InitialContext ctx = new InitialContext(env);
System.out.println("Looking up for queue");
System.out.println(ctx.lookup(queueName).getClass().getName());
Queue destination = (Queue) ctx.lookup(queueName);
System.out.println(destination.getQueueName());
System.out.println("Looking up for connection factory");
System.out.println(ctx.lookup(CFname).getClass().getName());
QueueConnectionFactory qcf = (QueueConnectionFactory)ctx.lookup(CFname);
System.out.println("getting connection");
QueueConnection conn = qcf.createQueueConnection("abc", "abc");
System.out.println("creating session");
QueueSession queueSession = conn.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
QueueSender sender = queueSession.createSender(destination);
TextMessage message = queueSession.createTextMessage();
message.setText("Test Message");
System.out.println("Sending Message...");
sender.send(message);
System.out.println("Finished Sending Message.");
sender.close();
conn.close();
queueSession.close();
} catch (Exception e) {
e.printStackTrace();
}
}
你能帮我解决这个问题吗?您需要任何其他信息来调试吗?