Glassfish Server JMS独立队列

时间:2014-06-05 15:19:17

标签: glassfish jms lookup

尝试在JMS中运行QUEUE:Producer代码时抛出错误。

java.lang.RuntimeException:Orb初始化erorr javax.naming.NamingException:SerialContext中的'myQueueConnectionFactory'查找失败[myEnv = {java.naming.factory.initial = com.sun.enterprise.naming.impl.SerialInitContextFactory,java.naming.factory.url.pkgs = com。 sun.enterprise.naming,java.naming.factory.state = com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [root异常是javax.naming.NamingException:无法获取SerialContext的SerialContextProvider [myEnv = { java.naming.factory.initial = com.sun.enterprise.naming.impl.SerialInitContextFactory,java.naming.factory.url.pkgs = com.sun.enterprise.naming,java.naming.factory.state = com.sun。 corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [根异常是java.lang.RuntimeException:Orb初始化erorr]]

我的代码是:

//Create and start connection  
            InitialContext ctx=new InitialContext();  
            QueueConnectionFactory f=(QueueConnectionFactory)ctx.lookup("myQueueConnectionFactory");  
            QueueConnection con=f.createQueueConnection();  
            con.start();  
            //2) create queue session  
            QueueSession ses=con.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);  
            //3) get the Queue object  
            Queue t=(Queue)ctx.lookup("myQueue");  
            //4)create QueueSender object         
            QueueSender sender=ses.createSender((t));  
            //5) create TextMessage object  
            TextMessage msg=ses.createTextMessage(); 

1 个答案:

答案 0 :(得分:0)

问题是您的应用程序无法查找()给定的JMS资源,而JavaxNaming会抛出异常。可能的原因:

- 我无法看到您将连接信息(属性)放到服务器的位置。通过调用不带参数的InitialContext()构造函数,您无法说明您尝试查找工厂和目标的提供程序URL和安全凭据。 (对不起,如果我在你的问题或你的逻辑中遗漏了什么)。

- 您是否在服务器上创建了JMS资源?

-Glassfish通常将工厂和destiantions存储在JMS文件夹中,因此要查找的路径可能必须是:

QueueConnectionFactory f=(QueueConnectionFactory)ctx.lookup("jms/myQueueConnectionFactory");
Queue t=(Queue)ctx.lookup("jms/myQueue");

您可以使用list-jms-resources子命令在远程asadmin模式下检查现有资源及其路径。

有关JMS资源创建和哈希的更多信息:look here