java - Connection to Weblogic JMS Queue fails -
i trying write message jms queue running on weblogic java.rmi.connectioexception when trying connect eclipse program.
javax.naming.communicationexception [root exception java.rmi.connectioexception: error during jrmp connection establishment; nested exception is: java.io.eofexception] @ weblogic.jrmp.context.lookup(context.java:189) @ weblogic.jrmp.context.lookup(context.java:195) @ javax.naming.initialcontext.lookup(unknown source) @ example.jms.queue.jmssender.sendmessage(jmssender.java:42) @ example.jms.queue.jmssender.main(jmssender.java:130) caused by: java.rmi.connectioexception: error during jrmp connection establishment; nested exception is: java.io.eofexception @ sun.rmi.transport.tcp.tcpchannel.createconnection(unknown source) @ sun.rmi.transport.tcp.tcpchannel.newconnection(unknown source) @ sun.rmi.server.unicastref.newcall(unknown source) @ weblogic.jrmp.baseremoteref.invoke(baseremoteref.java:221) @ weblogic.jrmp.registryimpl_stub.lookup(unknown source) @ weblogic.jrmp.context.lookup(context.java:185) ... 4 more caused by: java.io.eofexception @ java.io.datainputstream.readbyte(unknown source) ... 10 more exception in thread "main" java.lang.nullpointerexception @ example.jms.queue.jmssender.sendmessage(jmssender.java:47) @ example.jms.queue.jmssender.main(jmssender.java:130)
below client program
package example.jms.queue; import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstreamreader; import java.util.hashtable; import javax.jms.*; import javax.naming.context; import javax.naming.initialcontext; import javax.naming.namingexception; /** example shows how establish connection * , send messages jms queue. classes in * package operate on same jms queue. run classes * witness messages being sent , received, , browse queue * messages. class used send messages queue. * * @author copyright (c) 1999-2005 bea systems, inc. rights reserved. */ public class queuesend { // defines jndi context factory. public final static string jndi_factory="weblogic.jndi.wlinitialcontextfactory"; // defines jms context factory. public final static string jms_factory="jms/testconnectionfactory"; // defines queue. public final static string queue="jms/testjmsqueue"; private queueconnectionfactory qconfactory; private queueconnection qcon; private queuesession qsession; private queuesender qsender; private queue queue; private textmessage msg; /** * creates necessary objects sending * messages jms queue. * * @param ctx jndi initial context * @param queuename name of queue * @exception namingexception if operation cannot performed * @exception jmsexception if jms fails initialize due internal error */ public void init(context ctx, string queuename) throws namingexception, jmsexception { system.out.println("1"); qconfactory = (queueconnectionfactory) ctx.lookup(jms_factory); system.out.println("1"); qcon = qconfactory.createqueueconnection(); system.out.println("1"); qsession = qcon.createqueuesession(false, session.auto_acknowledge); system.out.println("1"); queue = (queue) ctx.lookup(queuename); qsender = qsession.createsender(queue); msg = qsession.createtextmessage(); qcon.start(); } /** * sends message jms queue. * * @param message message sent * @exception jmsexception if jms fails send message due internal error */ public void send(string message) throws jmsexception { msg.settext(message); qsender.send(msg); } /** * closes jms objects. * @exception jmsexception if jms fails close objects due internal error */ public void close() throws jmsexception { qsender.close(); qsession.close(); qcon.close(); } /** main() method. * * @param args weblogic server url * @exception exception if operation fails */ public static void main(string[] args) throws exception { try{ string url = "t3://localhost:7001"; url = "http://127.0.0.1:7001/testconnectionfactory/testjmsqueue"; //t://localhost:7001/connfact/queuename initialcontext ic = getinitialcontext(url); system.out.println("hello"); //system.out.println("context----" + ic.lookup(url)); queuesend qs = new queuesend(); system.out.println("initializing"); qs.init(ic, queue); system.out.println("sending"); readandsend(qs); system.out.println("sent"); qs.close(); }catch(exception ex){ ex.printstacktrace(); } } private static void readandsend(queuesend qs) throws ioexception, jmsexception { string line="test string 123"; // line = msgstream.readline(); qs.send(line); } private static initialcontext getinitialcontext(string url) throws namingexception { hashtable env = new hashtable(); env.put(context.initial_context_factory, jndi_factory); env.put(context.provider_url, url); return new initialcontext(env); } }
i have taken code oracle blog (https://blogs.oracle.com/soaproactive/entry/jms_step_2_using_the)
i see exception context lookup failing, cant suspect why ?
i fixed this. problem because of unwanted jars had added project. had added weblogic jars project. later removed jars , left wlclient.jar, wljmsclient.jar. suspected jar conflict while reading article on https://redstack.wordpress.com/2009/12/21/a-simple-jms-client-for-weblogic-11g/.
Comments
Post a Comment