wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Stand Alone JMS Application/Program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Stand Alone JMS Application/Program" Watch "Stand Alone JMS Application/Program" New topic
Author

Stand Alone JMS Application/Program

Monoranjan Gorai
Greenhorn

Joined: Jul 25, 2005
Posts: 19
I am running a stand alone jms program. Sample code is:
Properties env = new Properties();
env.setProperty(Context.PROVIDER_URL, "iiop://localhost:900");
env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");

InitialContext initCtx = new InitialContext();

System.out.println("Getting connection factory....");
// Finding the WAS QueueConnectionFactory
javax.jms.ConnectionFactory qcf = (javax.jms.ConnectionFactory) initCtx.lookup(JMSCF_JNDI_NAME);


while running the same I get the exception:
javax.naming.ConfigurationException: Name space accessor for the java: name space has not been set. Possible cause is that the user is specifying a java: URL name in a JNDI Context method call but is not running in a J2EE client or server environment.
javax.naming.ConfigurationException: Name space accessor for the java: name space has not been set. Possible cause is that the user is specifying a java: URL name in a JNDI Context method call but is not running in a J2EE client or server environment.
at com.ibm.ws.naming.java.javaURLContextFactory.isNameSpaceAccessable(javaURLContextFactory.java:98)
at com.ibm.ws.naming.urlbase.UrlContextFactory.getObjectInstance(UrlContextFactory.java:73)
at javax.naming.spi.NamingManager.getURLObject(NamingManager.java:579)
at javax.naming.spi.NamingManager.getURLContext(NamingManager.java:528)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:275)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at com.txlifeadapter.jms.MessageSender.<init>(MessageSender.java:47)
at com.txlifeadapter.jms.MessageClient.init(MessageClient.java:25)
at com.txlifeadapter.jms.MessageClient.main(MessageClient.java:53)
init2
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
Hi Monoranjan,

Pass the properties to the initial context like this:

Let me know if it works.
Regards.


I think, therefore I exist -- Rene Descartes
Monoranjan Gorai
Greenhorn

Joined: Jul 25, 2005
Posts: 19
My code is like the following:
env.setProperty(Context.PROVIDER_URL, "iiop://localhost:2809");
env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");

InitialContext initCtx = new InitialContext(env);

System.out.println("Getting connection factory....");
// Finding the WAS QueueConnectionFactory
javax.jms.ConnectionFactory qcf = (javax.jms.ConnectionFactory) initCtx.lookup(JMSCF_JNDI_NAME);
System.out.println("qcf="+qcf);
// Finding the Queue Destination
Destination q = (Destination) initCtx.lookup(JMSQ_JNDI_NAME);


I am getting exception as:

Oct 26, 2005 4:10:11 PM com.ibm.ws.naming.java.javaURLContextFactory
SEVERE: javaAccessorNotSet
javax.naming.ConfigurationException: Name space accessor for the java: name space has not been set. Possible cause is that the user is specifying a java: URL name in a JNDI Context method call but is not running in a J2EE client or server environment.
at com.ibm.ws.naming.java.javaURLContextFactory.isNameSpaceAccessable(javaURLContextFactory.java:98)
at com.ibm.ws.naming.urlbase.UrlContextFactory.getObjectInstance(UrlContextFactory.java:73)
at javax.naming.spi.NamingManager.getURLObject(NamingManager.java:579)
at javax.naming.spi.NamingManager.getURLContext(NamingManager.java:528)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:275)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at sender.Main.main(Main.java:29)
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
Hi Monoranjan,

Couple of hints:
  • Make sure that the JMS administrator created and bounded a JMS ConnectionFactory to jndi.
  • Make sure the name JMSCF_JNDI_NAME is correct (are you using java:comp/env/� for looking up the connection factory?).


  • Regards.
    Monoranjan Gorai
    Greenhorn

    Joined: Jul 25, 2005
    Posts: 19
    Hi,
    I have checked both then also getting the same error.
     
     
    subject: Stand Alone JMS Application/Program