Initial Context Lookup is getting failed some times
murthy516 Jul 11, 2013 2:34 PMHi All,
I'm using JBOSS 7.1.1.I'm trying to publish the message from one EAP server to the remote queue.standalone-full.xml,the queue is configured as
<jms-queue name="testQueue">
<entry name="queue/test"/>
<entry name="java:jboss/exported/jms/queue/test"/>
</jms-queue>
My Code to publish to the Queue is
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
env.put(Context.PROVIDER_URL, "remote://IPADDRESS:4447));
env.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces:org.jboss.naming");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, userName);
env.put(Context.SECURITY_CREDENTIALS, password);
ConnectionFactory connectionFactory=null;
InitialContext initialContext = new InitialContext(env);
connectionFactory = (ConnectionFactory) initialContext.lookup("jms/RemoteConnectionFactory"));
Queue queue = (Queue) initialContext.lookup("queue/test");
connection = connectionFactory.createConnection(userName,password);
Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
MessageProducer sender = session.createProducer(queue);
TextMessage message = session.createTextMessage(textMessage);
sender.send(message);
Some times it is being sent successfully.But some times it is giving the below exception:
javax.naming.NamingException: Failed to lookup [Root exception is org.jboss.remoting3.NotOpenException: Writes closed]
at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36)
at org.jboss.naming.remote.protocol.v1.Protocol$1.execute(Protocol.java:104)
at org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1.lookup(RemoteNamingStoreV1.java:79)
at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:79)
at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:83)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at net.treetechnologies.common.messaging.Publish.sendMessage(Publish.java:83)
at net.treetechnologies.order.airtel.services.PartyOrderManagementImpl.createXmlAndPublish(PartyOrderManagementImpl.java:545)
at sun.reflect.GeneratedMethodAccessor2887.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
I'm not getting why this is being happening some times even if the server is running.How to resolve this issue..Is there any workaround to resolve this...Please suggest me.
Thanks
Krishna