0
votes

Error thrown when am trying to run the QUEUE:Producer code in JMS.

java.lang.RuntimeException: Orb initialization erorr javax.naming.NamingException: Lookup failed for 'myQueueConnectionFactory' in SerialContext[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 exception is javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[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 exception is java.lang.RuntimeException: Orb initialization erorr]]

My code is:

//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

1 Answers

0
votes

The problem is that your application cannot lookup() the given JMS resources and JavaxNaming throws an exception. Possible reasons:

-I can't see where you put the connection info (Properties) to the server. By calling InitialContext() constructor without parameters you can't say from which provider url and security credentials you try to lookup the factory and destination. (Excuse me if i loose something in your question or your logic).

-Have you created the JMS resources on the server?

-Glassfish usually stores the factories and destiantions in JMS folder so the paths to be looked up probably have to be:

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

You can check the existing resources and their paths using list-jms-resources subcommand in remote asadmin mode.

For more information about JMS resources creation and hadling: look here