users@glassfish.java.net

NoInitialContextException when I try to lookup my ConnectionFactory

From: <glassfish_at_javadesktop.org>
Date: Sun, 08 Nov 2009 14:29:15 PST

Hello everyone,

I'm now working on a small project using JMS, and I have installed the last version of JDK 6 Update 17 With J2EE.

=======================================================
... ... ...
try{
        Context jndiContext = new InitialContext();
        connectionFactory = (ConnectionFactory)jndiContext.lookup("jms/ConnectionFactory");
        queue = (Queue)jndiContext.lookup("jms/queue");
}catch(NamingException exc){
        System.err.println("Lookup Object failed");
        exc.printStackTrace();
        System.exit(1);
}
... ... ...
=======================================================

When I tried to run the program above, I got a NoInitialContextException at the line : Context jndiContext = new InitialContext() . The full error message is:
=======================================================
javax.naming.NoInitialContextException: Cannot instantiate class: org.exolab.jms
.jndi.InitialContextFactory [Root exception is java.lang.ClassNotFoundException:
org.exolab.jms.jndi.InitialContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
57)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288
)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.&lt;init&gt;(InitialContext.java:175)
at SimpleMessageProducer.main(SimpleMessageProducer.java:49)
Caused by: java.lang.ClassNotFoundException: org.exolab.jms.jndi.InitialContextF
actory
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.jav
a:46)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
54)
... 4 more
=======================================================
I have created a javax.jms.ConnectionFactory and a javax.jms.Queue in the Glassfish Admin Consle -> Resources -> JMS Resources -> Connection Factories / Destinations Resources, and I have also added the appserv-rt.jar and javaee.jar into CLASSPATH. But my program still doesn't work.

I have tried to get my connection factory with the annotations @Resource, but it doesn't work either.

Si I'm "lookup" someone who could debug this program for me,

Greetings
[Message sent by forum member 'weepinsilence' (weepinsilence_at_gmail.com)]

http://forums.java.net/jive/thread.jspa?messageID=371092