jboss5.1下开发JMS时找不到QueueConnectionFactory

  今天在Jboss5.1下开发JMS时,调用如下代码出错:

  
  
QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup( " QueueConnectionFactory " );

错误异常信息为:

  
  
1 javax.naming.NameNotFoundException: QueueConnectionFactory not bound
2 at org.jnp.server.NamingServer.getBinding(NamingServer.java: 771 )
3 at org.jnp.server.NamingServer.getBinding(NamingServer.java: 779 )
4 at org.jnp.server.NamingServer.getObject(NamingServer.java: 785 )
5 ...................
6

解决办法:

  登陆jboss5.1的http://localhost:8090/jmx-console/,在这个jboss/service=JNDIView/list/Global JNDI Namespace下查找,只有ConnectionFactory!

  因此把发送消息的java类中的QueueConnectionFactory修改一下即可,如下:
  QueueConnectionFactory factory = (QueueConnectionFactory)ctx.lookup("QueueConnectionFactory");
  改为-->
  QueueConnectionFactory factory = (QueueConnectionFactory)ctx.lookup("ConnectionFactory");
  由此可以猜测到,在jboss5.1下,可能已经将P2P和PUB/SUB的ConnectionFactory作了一个整合,所以没有QueueConnectionFactory了.

你可能感兴趣的:(Connection)