8 Replies Latest reply on Dec 19, 2012 9:39 AM by tnas

    JNDI lookup for Hornetq in Jboss6

    grandhivenkatesh8787

      Hi every one,i'm using jboss 6.1...as it has inbuilt hornetq..the problem is...the client was unable to create a session to publish o subscribe messages..

       

      client proeperties that i'm using

       

      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory

      java.naming.provider.url=jnp://127.0.0.1:1099

      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

       

       

      Stack Trace:

       

      Exception in thread "main" javax.jms.JMSException: Failed to create session factory

                at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:605)

                at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:119)

                at test.test.testJMS.Subscriber.init(Subscriber.java:59)

                at test.test.testJMS.Subscriber.main(Subscriber.java:89)

      Caused by: java.lang.NullPointerException

                at org.hornetq.core.client.impl.ServerLocatorImpl.removeFromConnecting(ServerLocatorImpl.java:687)

                at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:756)

                at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:601)

                ... 3 more


        • 1. Re: JNDI lookup for Hornetq in Jboss6
          ataylor

          without any more info its impossible to help you, no doubt its a configuration issue somewhere, make sure that the connectors and acceptors are configured correctly.

          • 2. Re: JNDI lookup for Hornetq in Jboss6
            grandhivenkatesh8787

            Andy Taylor wrote:

             

            without any more info its impossible to help you, no doubt its a configuration issue somewhere, make sure that the connectors and acceptors are configured correctly.

            Hi Andy...the jboss 6 has some default configurations of horentq...and I am using the default one(localhost)...i have provide the configuration of it...

            • 3. Re: JNDI lookup for Hornetq in Jboss6
              ataylor

              its impossible for me to see what happening, I would suggest starting with some of the examples and go from there

              • 4. Re: JNDI lookup for Hornetq in Jboss6
                grandhivenkatesh8787

                Andy Taylor wrote:

                 

                its impossible for me to see what happening, I would suggest starting with some of the examples and go from there

                 

                I have tried the examples in Hornetq standalone...for my requirement i need to use the in-built horentq of Jboss 6.1.0.When we run a Jboss 6.1.0...it gives default configured queues...DLQ,ExpiryQueue and also i have configured  exampleQueue,exampleTopic as Queue and Topic names respectively..so I need to use these for publish and subscribe...while I push some messages...I am unable to create the session factory....

                I'm attaching the Sample Code to push some messages to the queue..please correct me if I'm wrong....and as a runtime argument I'm passing http://127.0.0.1:8080/invoker/JNDIFactoryt to the program

                 


                • 5. Re: JNDI lookup for Hornetq in Jboss6
                  ataylor

                  I have no idea, make sure you are using the correct client libs

                  • 6. Re: JNDI lookup for Hornetq in Jboss6
                    tnas

                    I'm stuck at this same problem. Could someone help us?

                    • 7. Re: JNDI lookup for Hornetq in Jboss6
                      jbertram

                      Can you be more specific (e.g. provide your client code and configuration)?

                      • 8. Re: JNDI lookup for Hornetq in Jboss6
                        tnas

                        Hi,

                         

                        It's the code I'm using. I've removed try/catch just to simplify the post here.

                         

                         

                        public class Publisher {

                          

                            private static ConnectionFactory connectionFactory;

                           

                            private static Topic topic;

                           

                            private static final byte NUM_MSG = 5;   

                           

                            public void publish() {

                               

                                Properties env = new Properties();

                                env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");

                                env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");

                                env.put(Context.PROVIDER_URL, "jnp://localhost:1099");

                               

                                Connection connection = null;

                         

                                Context ctx = new InitialContext(env);

                                connectionFactory = (TopicConnectionFactory) ctx.lookup("/ConnectionFactory");

                                topic = (Topic) ctx.lookup("/jms/MyTopic");

                                   

                                Destination dest = topic;

                                connection = connectionFactory.createConnection();

                                Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

                                MessageProducer producer = session.createProducer(dest);

                                TextMessage message = session.createTextMessage();

                         

                                for (int nMsg = 1; nMsg <= NUM_MSG; ++nMsg) {

                                    message.setText("This is a message " + nMsg + " from de Publisher.");

                                    System.out.println("Sending message: " + message.getText());

                                    producer.send(message);

                                }      

                        }

                         

                        <configuration xmlns="urn:hornetq"

                           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                           xsi:schemaLocation="urn:hornetq ../schemas/hornetq-jms.xsd ">

                           

                           <connection-factory name="ConnectionFactory">

                              <connectors>

                                 <connector-ref connector-name="netty"/>

                              </connectors>

                              <entries>

                                 <entry name="ConnectionFactory"/>

                              </entries>

                           </connection-factory>

                         

                           <topic name="MyTopic">

                              <entry name="/jms/MyTopic"/>

                           </topic>

                        </configuration>