13 Replies Latest reply on May 7, 2013 10:31 AM by fran_jo

    Configuration of JNDI

    fran_jo Newbie

      Hello everyone!

       

      How I should use and configure the hornetq-beans.xml in order to use the JNDI?? I want to follow the examples from a remote location.

       

      Do I have to initialize the hornetq server with a special parameter and/or configuration?

       

      Greetings!

        • 1. Re: Configuration of JNDI
          Andy Taylor Master
          1 of 1 people found this helpful
          • 2. Re: Configuration of JNDI
            fran_jo Newbie

            Ok,

             

            I use the hornetq 2.2.14 version, the configuration is the same. So, I have change the configuration following the manual:

             

             <!-- JNDI server. Disable this if you don't want JNDI -->
               <bean name="StandaloneServer" class="org.hornetq.jms.server.impl.StandaloneNamingServer">
                  <constructor>
                     <parameter>
                        <inject bean="HornetQServer"/>
                     </parameter>
                  </constructor>
                  <property name="port">${jnp.port:1099}</property>
                  <property name="bindAddress">${jnp.host:192.168.56.101}</property>
                  <property name="rmiPort">${jnp.rmiPort:1098}</property>
                  <property name="rmiBindAddress">${jnp.host:192.168.56.101}</property>
               </bean>
            

             

            When I run the server, with the appropriate path to my configuration, I get the following exception:

             

            * [main] 7-May 11:52:28,539 SEVERE [HornetQBootstrapServer]  Failed to start server
            java.lang.IllegalStateException: Incompletely deployed:
            
            
            DEPLOYMENTS IN ERROR:
              Deployment "StandaloneServer" is in error due to: java.lang.ClassNotFoundException: org.hornetq.jms.server.impl.StandaloneNamingServer
            
            
                    at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.internalValidate(AbstractKernelDeployer.java:278)
                    at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.validate(AbstractKernelDeployer.java:174)
                    at org.hornetq.integration.bootstrap.HornetQBootstrapServer.bootstrap(HornetQBootstrapServer.java:158)
                    at org.jboss.kernel.plugins.bootstrap.AbstractBootstrap.run(AbstractBootstrap.java:83)
                    at org.hornetq.integration.bootstrap.HornetQBootstrapServer.run(HornetQBootstrapServer.java:116)
                    at org.hornetq.integration.bootstrap.HornetQBootstrapServer.main(HornetQBootstrapServer.java:73)
            
            

             

            What could be the cause of this exception?

             

            Thanks!

            • 3. Re: Configuration of JNDI
              Andy Taylor Master

              that config is for 2.3.x only, refer to the appropriate docs to see what you need to configure

              • 4. Re: Configuration of JNDI
                fran_jo Newbie

                Ok,

                 

                The user manual of version 2.2.14 explains the same way to configure the JNDI Server

                • 6. Re: Configuration of JNDI
                  fran_jo Newbie

                  Sorry,  my fault, i was reading the manual of 2.3 and thought it was the correct one

                  • 7. Re: Configuration of JNDI
                    fran_jo Newbie

                    Ok,

                     

                    Now the server is running (I can not see any reference to the JNDI in the initial messages of the server) and the code that I use to get connection is this:

                     

                                Hashtable<String, String> env = new Hashtable<String, String>();
                                env.put(Context.PROVIDER_URL, "jnp://192.168.56.101:1099");
                                env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
                                env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
                                InitialContext ctx = new InitialContext(env);
                                
                                ConnectionFactory cf = (ConnectionFactory)ctx.lookup("/ConnectionFactory");
                                Queue queue = (Queue)ctx.lookup("/queue/FlowQueue");
                                connection = cf.createConnection();
                                Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                    
                    

                     

                    when I execute this code, I get the following error:

                     

                    javax.jms.JMSException: Failed to create session factory
                    

                     

                    Any idea?

                     

                    Thanks!

                    • 8. Re: Configuration of JNDI
                      Andy Taylor Master

                      have you configured your connectors correctly?

                      • 9. Re: Configuration of JNDI
                        fran_jo Newbie

                        Ok,

                         

                        In hornetq-configuration.xml I have this:

                         

                         

                                <!-- Specific connectors-->
                                <connector name="remote-netty">
                                        <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
                                        <param key="host" value="192.168.56.101"/>
                                        <param key="port" value="${hornetq.remoting.netty.port:5005}"/>
                                </connector>
                                <!-- -->
                        ...
                                <!-- Specific acceptors -->
                                <acceptor name="remote-netty">
                                        <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
                                        <param key="host" value="192.168.56.101"/>
                                        <param key="port"  value="${hornetq.remoting.netty.port:5005}"/>
                                </acceptor>
                                <!-- -->
                        

                         

                        With this configuration, I could connect using non JMS objects in the client code.

                        But if I set the same port of the JNDI configuration in this connector and acceptor, I get the next error when starting the server:

                         

                        * [main] 7-May 12:38:40,937 SEVERE [HornetQServerImpl]  Failure in initialisation
                        org.jboss.netty.channel.ChannelException: Failed to bind to: /192.168.56.101:1099
                        ...
                        

                         

                        There is something that I missunderstood about configuration...

                        • 10. Re: Configuration of JNDI
                          Andy Taylor Master

                          I dont understand why you are binding your netty ports to the ssame port that jndi is using? they have to be different

                          • 11. Re: Configuration of JNDI
                            fran_jo Newbie

                            Ok,

                             

                            They are different now, but I can not connect to the JNDI Server

                            • 12. Re: Configuration of JNDI
                              Andy Taylor Master

                              I cant really help you without the full info, simple set the netty acceptor to the port you want HornetQ to bind to, set the connector to the the port you want the conenction factory to connect to and set the jndi address to the host/port you want the initial context to connect to.

                              • 13. Re: Configuration of JNDI
                                fran_jo Newbie

                                Let's see,

                                 

                                I have the hornetq-beans.xml configured like this:

                                 

                                <!-- JNDI server. Disable this if you don't want JNDI -->
                                   <bean name="JNDIServer" class="org.jnp.server.Main">
                                      <property name="namingInfo">
                                         <inject bean="Naming"/>
                                      </property>
                                      <property name="port">${jnp.port:1099}</property>
                                      <property name="bindAddress">${jnp.host:192.168.56.101}</property>
                                      <property name="rmiPort">${jnp.rmiPort:1098}</property>
                                      <property name="rmiBindAddress">${jnp.host:192.168.56.101}</property>
                                   </bean>
                                
                                

                                 

                                And the hornetq-configuration.xml configured like this:

                                 

                                 <!-- Specific connectors-->
                                        <connector name="remote-netty">
                                                <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
                                                <param key="host" value="192.168.56.101"/>
                                                <param key="port" value="${hornetq.remoting.netty.port:5005}"/>
                                        </connector>
                                        <!-- -->
                                ...
                                        <!-- Specific acceptors -->
                                        <acceptor name="remote-netty">
                                                <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
                                                <param key="host" value="192.168.56.101"/>
                                                <param key="port"  value="${hornetq.remoting.netty.port:5005}"/>
                                        </acceptor>
                                        <!-- -->
                                

                                 

                                and run the server with this instruction:

                                 

                                ./run.sh /home/user/my_hornetq_config/
                                

                                 

                                The server runs ok. But when I execute the following code, I can not access to the server:

                                 

                                Hashtable<String, String> env = new Hashtable<String, String>();
                                            env.put(Context.PROVIDER_URL, "jnp://192.168.56.101:1099");
                                            env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
                                            env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
                                            InitialContext ctx = new InitialContext(env);
                                            
                                            ConnectionFactory cf = (ConnectionFactory)ctx.lookup("/ConnectionFactory");
                                            Queue queue = (Queue)ctx.lookup("/queue/FlowQueue");
                                            connection = cf.createConnection();
                                            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                                

                                 

                                The server is inside a VirtualBox, under Ubuntu Server 12.04. The connection between my host (win xp) and the guest (ubuntu) works well. The IP 192.168.56.101 is the address to communicate the guest with the host. When I access to the server using the connector's port, with the hornetq core objects the communication works well. But I want to access via JNDI.