5 Replies Latest reply on Apr 25, 2013 9:17 AM by ataylor

    HornetQ in Ubuntu Server 12.04 through VirtualBox

    fran_jo

      Hello everyone!

       

      I am working in Windows XP and I have recently set up a Ubuntu Server 12.04 as a guest, using Virtual Box. I want to set up HornetQ (version 2.2.14) to be accessed from the host (WinXP).

       

      I want to run the HornetQ server as a stand-alone server, so I add the following configuration to the hornetq-configuration.xml:

       

       

       

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

       

      (see that the 10.0.2.15 is the IP address of the eth0 from Ubuntu Server)

       

      and to the hornetq-jms.xml:

         <connection-factory name="NettyConnectionFactory">
            <xa>false</xa>
            <connectors>
               <connector-ref connector-name="remote-netty"/>
            </connectors>
            <entries>
               <entry name="/RTConnectionFactory"/>
            </entries>
         </connection-factory>
      
      

       

      I also create a VirtualBox port, using a NAT adapter that points to this configuration, something like this:

       

      Port Name
      Protocol
      Host IP
      PortGuest IP
      Port
      hornetqtcpmyIP500510.0.2.155005

       

       

      With this configuration, I try to execute the Queue example but

                

                  // Step 1. Create an initial context to perform the JNDI lookup.
                  Hashtable<String, String> env = new Hashtable<String, String>();
                  env.put(Context.PROVIDER_URL, "jnp://myIP:5005");
                  env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
                  env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces  ");
                  initialContext = new InitialContext(env);
      
      
                  // Step 2. Perfom a lookup on the queue
                  Queue queue = (Queue)initialContext.lookup("/queue/OrderQueue");
      
      
                  // Step 3. Perform a lookup on the Connection Factory
                  ConnectionFactory cf = 
                          (ConnectionFactory)initialContext.lookup("/RTConnectionFactory");
      

       

      But I get communication error like this:

      javax.naming.CommunicationException: Could not obtain connection to any of these urls: myIP:5005
      

       

      Does any one experience this problem? Or do you have any idea about what could be wrong?

       

      Greetings!

        • 1. Re: HornetQ in Ubuntu Server 12.04 through VirtualBox
          gaohoward

          5005 is not your jndi listening port. You need use your real jndi port (default 1099) in your context property

           

          evn.put(Context.PROVIDER_URL, "jnp://myIP:<JNDI LISTENING PORT>

          • 2. Re: HornetQ in Ubuntu Server 12.04 through VirtualBox
            fran_jo

            Ok,

             

            So, I have checked out the hornetq-beans.xml file and edit this config file 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:5004}</property>
                  <property name="bindAddress">${jnp.host:10.0.2.15}</property>
                  <!--
                  <property name="port">${jnp.port:1099}</property>
                  <property name="bindAddress">${jnp.host:localhost}</property>
                  -->
                  <property name="rmiPort">${jnp.rmiPort:1098}</property>
                  <property name="rmiBindAddress">${jnp.host:localhost}</property>
               </bean>
            

             

            and modify the virtual box routing table to modify the port to the new one: 5004

             

            Now I get a different exception:

            javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
            

             

            Do I have to change anything in the hornetq-beans.xml?

             

            Thanks!

            • 3. Re: HornetQ in Ubuntu Server 12.04 through VirtualBox
              gaohoward

              I think you should change the rmi bind address too.

               

              <property name="rmiBindAddress">${jnp.host:10.0.2.15}</property>

              • 4. Re: HornetQ in Ubuntu Server 12.04 through VirtualBox
                fran_jo

                Ok,

                 

                It still does not work. I supose all the config files are setted up well. When I try to connect via the netty port, myIP:5005 I get this error in the hornetq:

                * [hornetq-failure-check-thread] 25-Apr 14:54:29,643 WARNING [RemotingConnectionImpl]  Connection failure has been detected: Did not receive data from /10.0.2.2:1619. It is likely the client has exited or crashed without closing its connection, or the network between the server and client has failed. You also might have configured connection-ttl and client-failure-check-period incorrectly. Please check user manual for more information. The connection will now be closed. [code=3]
                

                so I guess it may be a problem with connectin to the server via VirtualBox.

                 

                I will keep on investigating.

                 

                Thanks!

                • 5. Re: HornetQ in Ubuntu Server 12.04 through VirtualBox
                  ataylor

                  moved this to the hornetq user forum where it belongs