8 Replies Latest reply on Dec 12, 2012 4:13 AM by Bjorn Water

    [question] Send message to remote hornetQ

    Bjorn Water Newbie

      Hi,

       

      I am trying to migrate my application from jboss 5 GA to jboss 7 AS.

      Im loving all the new features but i am hitting a problem.

       

      For my log system i sent a message to a queue that is on a different server then the jboss AS.

      This queue is managed by hornet.

       

      I used to do it likes this

       

       

       

                                       
           
                                     String adsLogConnectionFactory = "/ConnectionFactory";
                                      String adsLogQueueLookup = "/queue/adsLogQueue"
      
                                      String providerUrl = "localhost:1099,localhost:10990";
                                Hashtable<String, String> env = new Hashtable<String, String>();
                                    env.put(Context.PROVIDER_URL, providerUrl);
                                    env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
                                    env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
        
                                    Context ctx = new InitialContext(env);
        
                                    ConnectionFactory cf = (ConnectionFactory) ctx.lookup(adsLogConnectionFactory);
      
                                Queue queue = (Queue) ctx.lookup(adsLogQueueLookup);
                                    connection = cf.createConnection();
                                    session = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
                                    MessageProducer producer = session.createProducer(queue);
                                    ObjectMessage message = session.createObjectMessage(createLog(trackable, operationName));
                                    producer.send(message);
      
      
                                    log.info("A trackable was sent to adsLogQueue: MessageId:" + message.getJMSMessageID() + ", timestamp: "
                                                        + SimpleDateFormat.getInstance().format(new Date(message.getJMSTimestamp())));
      
      

       

       

      This worked fine in jboss 5 but in jboss 7 i get the following error.

       

      javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jnp.interfaces.NamingContextFactory from classloader ModuleClassLoader for Module "deployment.ORTS-ear-1.0-rc140-SNAPSHOT.ear.ORTS-lib-1.0-rc140-SNAPSHOT.jar:main" from Service Module Loader

       

       

      So i checked the internet and tried to following.

       

       

      final Properties env = new Properties();
                                    env.put(Context.INITIAL_CONTEXT_FACTORY, org.jboss.naming.remote.client.InitialContextFactory.class.getName());
                                    env.put(Context.PROVIDER_URL, "remote://localhost:1099");
                                    env.put(Context.SECURITY_CREDENTIALS, "testpassword");
                                    env.put(Context.SECURITY_PRINCIPAL, "testuser");
      
      

       

      16:46:25,461 ERROR [stderr] (pool-11-thread-1) javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException: Operation failed with status WAITING]

       

      16:46:25,464 ERROR [stderr] (pool-11-thread-1)           at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36)

        16:46:25,466 ERROR [stderr] (pool-11-thread-1)           at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:117)

        16:46:25,469 ERROR [stderr] (pool-11-thread-1)           at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)

        16:46:25,471 ERROR [stderr] (pool-11-thread-1)           at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)

        16:46:25,473 ERROR [stderr] (pool-11-thread-1)           at javax.naming.InitialContext.init(InitialContext.java:223)

        16:46:25,483 ERROR [stderr] (pool-11-thread-1)           at javax.naming.InitialContext.<init>(InitialContext.java:197)

        16:46:25,484 ERROR [stderr] (pool-11-thread-1)           at com.cliqdigital.orts.service.ORTSImpl.logTrackableJMS(ORTSImpl.java:259)

        16:46:25,485 ERROR [stderr] (pool-11-thread-1)           at com.cliqdigital.orts.service.ORTSImpl.access$400(ORTSImpl.java:91)

        16:46:25,486 ERROR [stderr] (pool-11-thread-1)           at com.cliqdigital.orts.service.ORTSImpl$2.run(ORTSImpl.java:228)

        16:46:25,506 ERROR [stderr] (pool-11-thread-1)           at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

        16:46:25,509 ERROR [stderr] (pool-11-thread-1)           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

        16:46:25,510 ERROR [stderr] (pool-11-thread-1)           at java.lang.Thread.run(Thread.java:662)

        16:46:25,511 ERROR [stderr] (pool-11-thread-1) Caused by: java.lang.RuntimeException: Operation failed with status WAITING

        16:46:25,515 ERROR [stderr] (pool-11-thread-1)           at org.jboss.naming.remote.protocol.IoFutureHelper.get(IoFutureHelper.java:89)

        16:46:25,519 ERROR [stderr] (pool-11-thread-1)           at org.jboss.naming.remote.client.cache.ConnectionCache.get(ConnectionCache.java:42)

        16:46:25,520 ERROR [stderr] (pool-11-thread-1)           at org.jboss.naming.remote.client.InitialContextFactory.createConnection(InitialContextFactory.java:153)

        16:46:25,530 ERROR [stderr] (pool-11-thread-1)           at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateConnection(InitialContextFactory.java:126)

        16:46:25,531 ERROR [stderr] (pool-11-thread-1)           at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:106)

        16:46:25,532 ERROR [stderr] (pool-11-thread-1)           ... 10 more

       

      If someone could help me with my problem i would appreciate it.

      If you need any more information please ask.

       

      Thanks in advance,

       

      Bjørn