I am trying to write a standalone client that writes to a jms queue.
So far, I can't even do a simple jndi lookup.
I am using Sun Java Application Server 8, running on the localhost. I created a QueueConnectionFactory called queueConnectionFactory and a Queue called testQueue.
I tried using
"java:comp/env/jms/queueConnectionFactory", "java:jms/queueConnectionFactory",
and "queueConnectionFactory"
.
I tried including all of the jar files included with Sun AS 8.
Anyone know what I am doing wrong?
import java.util.*;
import javax.jms.*;
import javax.naming.*;
public class TestSender {
private QueueConnectionFactory queueConnectionFactory = null;
private Queue queue = null;
private Context jndiContext = null;
/**
* Creates a new TestSender object.
*/
public TestSender() {
try {
Properties props = new Properties();
props.put("java.naming.factory.initial", "com.sun.jndi.cosnaming.CNCtxFactory");
props.put("java.naming.provider.url", "iiop://localhost:3700");
jndiContext = new InitialContext(props);
} catch (NamingException e) {
System.out.println("Could not create JNDI " + "context: " + e.toString());
System.exit(1);
}
try {
queueConnectionFactory = (QueueConnectionFactory) jndiContext.lookup("queueConnectionFactory");
} catch (NamingException e) {
System.out.println("JNDI lookup failed: " + e.toString());
e.printStackTrace();
System.exit(1);
}
}
public static void main(String[] args) {
TestSender testSender1 = new TestSender();
}
}
When I run this, I get:
javax.naming.NameNotFoundException [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]
at com.sun.jndi.cosnaming.ExceptionMapper.mapException(ExceptionMapper.java:44)
at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:453)
at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:492)
at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:470)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at sunmqtest.test.TestSender.<init>(TestSender.java:27)JNDI lookup failed: javax.naming.NameNotFoundException [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]
at sunmqtest.test.TestSender.main(TestSender.java:36)
Caused by: org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:72)
at org.omg.CosNaming._NamingContextExtStub.resolve(_NamingContextExtStub.java:406)
at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:440)