1 Reply Latest reply on Apr 14, 2014 2:38 PM by muktesh mishra

    Jboss 6 : Not able to push messages in Jboss 4.2.2.GA queue

    muktesh mishra Newbie

      Recently we have upgraded to from Jboss4.2.2.GA to Jboss6.1.0.Final.

       

      Now we have a queue set up (.ear ) deployed on Jboss 4.2.2.GA, in which we are trying to push messages from our client deployed on JBoss6.1.0.Final.

       

      However when we tries to push messages it is throwing  exception like:

       

      Error setting up JMS

      javax.naming.NameNotFoundException: A not bound

       

      Further stack traces are as follows:

      2014-04-06 21:04:07,719 INFO  [STDOUT] (pool-15-thread-2) [pool-15-thread-2] 2014-04-06 21:04:07,718 INFO  (MessagePublisher.java:29) - get JMS Intansce

      2014-04-06 21:04:07,720 INFO  [STDOUT] (pool-15-thread-2) [pool-15-thread-2] 2014-04-06 21:04:07,719 DEBUG (MessagePublisher.java:152) - jnp://xxx1.com:1400,jnp://xxx.com:1400

      2014-04-06 21:04:07,801 INFO  [STDOUT] (pool-15-thread-2) [pool-15-thread-2] 2014-04-06 21:04:07,799 ERROR (MessagePublisher.java:96) - Error setting up JMS

      2014-04-06 21:04:07,801 INFO  [STDOUT] (pool-15-thread-2) javax.naming.NameNotFoundException: A not bound

      2014-04-06 21:04:07,801 INFO  [STDOUT] (pool-15-thread-2)       at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)

      2014-04-06 21:04:07,801 INFO  [STDOUT] (pool-15-thread-2)       at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)

      2014-04-06 21:04:07,801 INFO  [STDOUT] (pool-15-thread-2)       at org.jnp.server.NamingServer.getObject(NamingServer.java:785)

      2014-04-06 21:04:07,801 INFO  [STDOUT] (pool-15-thread-2)       at org.jnp.server.NamingServer.lookup(NamingServer.java:443)

      2014-04-06 21:04:07,801 INFO  [STDOUT] (pool-15-thread-2)       at org.jnp.server.NamingServer.lookup(NamingServer.java:399)

      2014-04-06 21:04:07,801 INFO  [STDOUT] (pool-15-thread-2)       at org.jboss.ha.jndi.HAJNDI.lookupLocally(HAJNDI.java:188)

      2014-04-06 21:04:07,801 INFO  [STDOUT] (pool-15-thread-2)       at org.jboss.ha.jndi.HAJNDI.lookup(HAJNDI.java:135)

      2014-04-06 21:04:07,801 INFO  [STDOUT] (pool-15-thread-2)       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      2014-04-06 21:04:07,801 INFO  [STDOUT] (pool-15-thread-2)       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

      2014-04-06 21:04:07,801 INFO  [STDOUT] (pool-15-thread-2)       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      2014-04-06 21:04:07,801 INFO  [STDOUT] (pool-15-thread-2)       at java.lang.reflect.Method.invoke(Method.java:597)

      2014-04-06 21:04:07,801 INFO  [STDOUT] (pool-15-thread-2)       at org.jboss.ha.framework.interfaces.HARMIClient.invoke(HARMIClient.java:318)

      2014-04-06 21:04:07,801 INFO  [STDOUT] (pool-15-thread-2)       at $Proxy287.lookup(Unknown Source)

      2014-04-06 21:04:07,801 INFO  [STDOUT] (pool-15-thread-2)       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:728)

      2014-04-06 21:04:07,801 INFO  [STDOUT] (pool-15-thread-2)       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688)

      2014-04-06 21:04:07,801 INFO  [STDOUT] (pool-15-thread-2)       at javax.naming.InitialContext.lookup(InitialContext.java:392)

       

       

       

      Client code is as  follows:

       

        private static MessagePublisher JMSClientInstance = new MessagePublisher();

       

        private MessagePublisher() {

        LOG.info("get JMS Intansce");

        setUpJMS();

        }

       

        public static MessagePublisher getInstance() {

        return JMSClientInstance;

        }

       

        volatile boolean doSend = true;

        private ConnectionFactory connectionFactory;

        private Destination queue;

        private Connection connection;

        private Session session;

        private MessageProducer producer;

       

        private boolean setUpJMS() {

        InitialContext ic;

        try {

        ic = getInitialContext();

        connectionFactory = (ConnectionFactory) ic.lookup("ConnectionFactory");

        queue = (Destination) ic.lookup("queue/A");

        System.out.println("queue is--->"+queue);

        connection = connectionFactory.createConnection();

        try {

        LOG.info("Connection created ...");

       

        // KEY - register for exception callbacks

        connection.setExceptionListener(new ExceptionListenerImpl());

       

        session = connection.createSession(false,

        Session.AUTO_ACKNOWLEDGE);

        LOG.info("Session created ...");

        producer = session.createProducer(queue);

       

        producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

        LOG.info("Producer created ...");

       

        return true;

        } catch (Exception e) {

        // We failed so close the connection

        try {

        connection.close();

        } catch (JMSException ignored) {

        }

       

        throw e;

        } finally {

       

        ic.close();

        }

        } catch (Exception e) {

        LOG.error("Error setting up JMS",e);

        return false;

        }

        }

       

        public void sendMessages(String message) {

        if(doSend){

        try {

        LOG.info("Preparing to send message...");

        Message m = session.createTextMessage(message);

        producer.send(m);

        LOG.info("message sent "+m.getJMSMessageID());

        } catch (Exception e) {

        LOG.error("Exception while sending message",e);

        }

        }

        }

       

        private class ExceptionListenerImpl implements ExceptionListener {

        public void onException(JMSException e) {

       

        for (int i = 0; i < NUM_RETRIES; i++) {

        LOG.info("Connection has problems, trying to re-create it, attempt "

        + (i + 1) + " ...");

       

        try {

        connection.close(); // unregisters the ExceptionListener

        } catch (Exception e2) {

       

        }

       

        boolean setupOK = setUpJMS();

       

        if (setupOK) {

        LOG.info("Connection re-established");

        return;

        } else {

        LOG.info("Re-creating connection failed, retrying ...");

        }

        }

       

        LOG.info("Cannot re-establish connection, giving up ...");

        doSend = false;

        }

        }

       

        private InitialContext getInitialContext() throws NamingException {

        Properties jboss = new Properties();

        jboss.put("java.naming.factory.initial",

        "org.jnp.interfaces.NamingContextFactory");

        jboss.put("java.naming.factory.url.pkgs",

        "org.jboss.naming:org.jnp.interfaces");

      //SERVER_JMS_IPS= IP and hajndi port viz: xxx.com:<hajndi-port>

        LOG.debug(System.getProperty(Constants.SERVER_JMS_IPS));

        jboss.put("java.naming.provider.url", System.getProperty(Constants.SERVER_JMS_IPS));

        return new InitialContext(jboss);

       

        }

       

      I also tried putting jnp:// in queue urls, but it also didn't work.

       

       

      Note: Above code and queue set up was working fine when our client was deployed jboss4.2.2.GA (earlier), then problem comes only after we upgrade on Jboss6 for deployed client.)

       

      Can anybody please help.

       

      Any help will be deeply appreciated.

       

      Thanks,

      Muktesh