2 Replies Latest reply on May 10, 2013 8:51 AM by Michael Illgner

    EJB as a JMS client ?

    Michael Illgner Newbie

      Hi folks

      I want so send JMS messages from an EJB to another JMS Server in my network, so the JBoss AS 7 acts as an JMS client to the other server.

       

      My code already works as a standalone simple java applciation, but when I use this code inside an EJB I got a ClassNotFoundException

       

      at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_17]

       

      Caused by: org.jboss.naming.remote.protocol.NamingIOException: Failed to lookup [Root exception is java.io.IOException: java.lang.ClassNotFoundException: org.hornetq.jms.client.HornetQJMSConnectionFactory from [Module "deployment.Dispatcher.jar:main" from Service Module Loader]]

       

      at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:49)
      at org.jboss.naming.remote.protocol.v1.Protocol$1.execute(Protocol.java:104)
      at org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1.lookup(RemoteNamingStoreV1.java:78)
      at org.jboss.naming.remote.client.HaRemoteNamingStore$1.operation(HaRemoteNamingStore.java:227)
      at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:119)
      at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:223)
      at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:79)
      at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:83)

      at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_17]

       

      I assume I have to add some dependeny / module description to the MANIFEST of the EJB jar, but I cannot find aan hornetq/jms client module .

       

      Any ideas ?

       

       

      Thanks

      Michael

        • 1. Re: EJB as a JMS client ?
          Stephen Coy Master

          Are both servers running AS7? If so, what version?

           

          Also, show the code you're using to send messages, including the lookups.

          • 2. Re: EJB as a JMS client ?
            Michael Illgner Newbie

            This is my lookup code

             

               

            import java.util.Hashtable;

             

            mport javax.jms.Connection;

            import javax.jms.ConnectionFactory;

            import javax.jms.DeliveryMode;

            import javax.jms.JMSException;

            import javax.jms.MessageProducer;

            import javax.jms.Queue;

            import javax.jms.Session;

            import javax.jms.TextMessage;

            import javax.naming.Context;

            import javax.naming.InitialContext;

             

             

            Hashtable<String, String> env = new Hashtable<String, String>();
                  env.put(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
                  env.put(InitialContext.PROVIDER_URL, "remote://localhost:4447");
               

            Context ctx = new InitialContext(env);

            Queue queue = (Queue) ctx.lookup("jms/queue/loader");



             

            I have found  the following solution, just add org.hornetq and org.jboss.remote-naming to the dependencies in the ejb MANIFEST file