users@glassfish.java.net

JMS test client inside NetBeans requires java.naming.factory.initial

From: <glassfish_at_javadesktop.org>
Date: Sun, 04 May 2008 05:04:23 PDT

I have a very simple program in which I am only trying to connect to the JMS ConnectionFactory. Here is my code:
----------------------------------
InitialContext ic = new InitialContext();
ConnectionFactory connFactory = (ConnectionFactory)ic.lookup("jms/AgentConnectionFactory");
Queue mQueue = (Queue)ic.lookup("jms/AgentDestination");
                
Connection connection = connFactory.createConnection();
Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);


Here is the exception:
----------------------------------
run-main:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
        at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
        at javax.naming.InitialContext.lookup(InitialContext.java:351)
        at org.markwebb.jms.JmsSender.sendMessage(JmsSender.java:32)
        at org.markwebb.jms.JmsSender.main(JmsSender.java:24)


Can someone help me out or show me a working example of JMS with Glassfish?
Thanks
[Message sent by forum member 'elihusmails' (elihusmails)]

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