4 Replies Latest reply on Sep 9, 2004 6:19 PM by harajuku_01

    JmsXA not bound

    harajuku_01 Newbie

      I have unzipped the jboss-3.2.3.zip and use it as is. When I run the following code, I get the above error. Is there anything I need to configure? Thanks a lot.

      ht.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
      ht.put(Context.PROVIDER_URL,"jnp://myhost:1099");

      ctx = new InitialContext(ht);
      QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup("java:/JmsXA");

      =====================================
      javax.naming.NameNotFoundException: JmsXA not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
      at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:282)
      at sun.reflect.GeneratedMethodAccessor84.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:536)
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
      at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
      at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:528)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)
      at JbTxClient.init(JbTxClient.java:64)
      at JbTxClient.main(JbTxClient.java:120)

        • 1. Re: JmsXA not bound
          Elias Ross Master


          Not sure what you want to do, but just do

          new InitialContext().lookup("java:/JmsXA") from within JBoss.

          • 2. Re: JmsXA not bound
            harajuku_01 Newbie

            genman, thanks for your reply.

            Basically, this is a stand-alone java client program. From this client, I want to send a JMS message in a transactional context to JBoss and be able to control when to call commit(). My code is as follows. I also tried in a different program using XAQueueConnection instead of QueueConnection but it didn't work and gave error "Invalid transaction id". So I search this forum that most people mentioned that java:/JmsXA should be used together with QueueConnectionFactory. That's how I come up with this error. May be I didn't get the concept right.

            Thanks in advance.

            =============================================

            Hashtable ht = new Hashtable();
            ht.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
            ht.put(Context.PROVIDER_URL,"jnp://myhost:1099");

            Context ctx = new InitialContext(ht);

            UserTransaction m_tx = (UserTransaction)ctx.lookup("UserTransaction");

            // QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup("XAConnectionFactory");
            QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup("java:/JmsXA");

            QueueConnection conn = qcf.createQueueConnection();
            conn.start();

            QueueSession session = conn.createQueueSession(true, QueueSession.AUTO_ACKNOWLEDGE);
            Queue queA = (Queue) ctx.lookup("queue/A");


            // begin Transaction
            m_tx.begin();

            QueueSender send = session.createSender(queA);
            TextMessage tm = session.createTextMessage("Timestamp: ["+ new Date() +"]");
            send.send(tm);

            Thread.sleep(10000);

            m_tx.commit();

            • 3. Re: JmsXA not bound
              Darran Lofthouse Master

              Items bound to the java: namespace can only be accesses from within the JBoss JVM and then only if you don't provide a PROVIDER_URL to the InitialContext constructor.

              I am not sure how other people would approach this but unless the client really needs to know that it is using a Queue I would wrap access to the queue with a session bean, that way if at any time you need to change from asynchronous to synchronous processing you can without changing the client.

              • 4. Re: JmsXA not bound
                harajuku_01 Newbie

                Thanks darranl.

                I was trying to send JMS message directly to a queue inside JBossMQ and hopefully to be able to control when to call the UserTransaction.begin() and UserTransaction.commit(). Now I will try your approach.