0 Replies Latest reply on Jan 27, 2009 6:02 AM by kutts4u

    JNDI lookup fail for Websphere MQ Administered objects

    kutts4u Newbie


      I am trying to interface a web application with Websphere MQ series. The basic requirement is that I need to send a xml message to a MQ queue. And then listen to another MQ queue for the response and display the response back to the web user.

      I tried a simple program that worked OK as follows -

      1. Created/ Defined the Websphere MQ Connection factory / Queue using the JMSAdmin tool (Webspeher MQ 6.0 is installed on Solaris 10).

      2. The JNDI context used for the JMSAdmin tool was the JNDI namespace of the JBoss server that is on another machine.
      The JNDI was sucessfully accepted by JMSAdmin since the following is displayed when starting JMSAdmin

      Initializing JNDI Context...
      INITIAL_CONTEXT_FACTORY: org.jnp.interfaces.NamingContextFactory
      PROVIDER_URL: jnp://

      3. Defined the connection factory as follows
      DEFINE CF(java:/jms.cnxFactory) +
      TRAN(client) +

      DEFINE Q(java:/jms.myOwnQueue) QMGR(MYSRV.QMGR) QUEUE(MYQUEUE)

      4. I wrote a simple java program that did the following

      java.util.Hashtable environment = new java.util.Hashtable();
      environment.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      environment.put(Context.PROVIDER_URL, "jnp://");
      Context ctx = new InitialDirContext( environment );
      ConnectionFactory factory = (ConnectionFactory) ctx.lookup("java:/jms.cnxFactory");

      And then I did a lookup of the queue and was able to put messages to the MQ sucessfully. I was also able to read from the same queue via JMS.

      5. I then tried out the same on my web application that uses struts - ejb (session beans only). I did the same call as above from my struts layer. I was expecting the context to be retrived and that I can send the messages. But I got a Naming exception saying the jndi name was not bound. The web application is deployed on the same Jboss server.

      Why is it that the jndi lookup fails when called from the web application while it is OK from a simple java program that is outside the jboss container ?

      6. I would want to move the context looup and send / receive of messages via JMS into/from the MQ queue using session beans. I could only find MDB examples. My requirement requires that I manage the transaction such that session bean handles the message send / recieve to simulate a synchronous call. So, I cannot use MDB since it would then be async. Any thought on where I could get some documentation to configure Jboss to allow the session beans to do the jndi lookup to the JMS queues whihc have teh Webpshere MQ as the provider ?