This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stand Alone JMS Application/Program

 
Monoranjan Gorai
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Monoranjan,

Pass the properties to the initial context like this:

Let me know if it works.
Regards.
 
Monoranjan Gorai
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
    Posts: 19
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi,
    I have checked both then also getting the same error.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic