setting JNDI name


General J2EE: setting JNDI name

  1. setting JNDI name (1 messages)


    Iam trying to execute simple jms programs in WSAD.
    I write simple Sender and Receiver programs and started the WSAD test envirinment and set the JNDI names for QueueConnctionFactory, Queue.
    Now my doubt is how to lookup QueueConnectionFactor in my programs.
    I tried as follows,
    queueConnectionFactory = (QueueConnectionFactory)
                queue = (Queue) jndiContext.lookup("Java:comp/env/queueName");

     but it is giving error

    JNDI API lookup failed: javax.naming.NoInitialContextException: Need to specify
    class name in environment or system property, or as an applet parameter, or in a
    n application resource file: java.naming.factory.initial

    plz give me suitable answer.....
  2. setting JNDI name[ Go to top ]

    Hi Srikanth,

    I am not sure this is the answer to your issue or not....but when I did a JNDI lookup to a JMS queue on WebSphere I had to add some WebSphere specific stuff to the lookup:


    System.out.println("Setting WebSphere specific properties");
                     Properties props = new java.util.Properties();
                     props.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY, "");
                     props.setProperty(InitialContext.PROVIDER_URL, "iiop://wb-mfoley:2809");
                     props.setProperty(InitialContext.URL_PKG_PREFIXES, "");
                     System.out.println("Setting variables for this particular test");

                    System.out.println("Getting the InitalContext()");
    jndiContext = new InitialContext(props);

    Maybe this will help....