title: HornetQ - ConnectionFactory exception when the JMS server and queue is hosted remotely
body: <p>I am trying to run the Queue example code that comes with HornetQ 2.2.5 final release.  Path is $INSTALL_ROOT/examples/jms/queue.</p>
  
  <p>This example works fine when I run everything on the localhost.  But when I change the configuration so that the JMS server is on a remote host, I am getting a session error from the HornetQConnectionFactory.  The client finds the JNDI service on the remote host, but fails when it tries to establish a JMS connection.  The following is the error stack.</p>
  
  <pre><code>$ ./build.sh runRemote
  ...
  runExample:
       [java] serverProps = -XX:+UseParallelGC -Xms256M -Xmx256M -XX:+AggressiveOpts
              -XX:+UseFastAccessorMethods -Dcom.sun.management.jmxremot   
           -Djava.util.logging.config.file=/ecm/packages/hornetq-2.2.5.Final/examples/common/config
           /logging.properties
           -Djava.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
            -Djava.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces 
       [java] Dec 22, 2011 5:54:42 PM org.hornetq.common.example.HornetQExample run
       [java] INFO: hornetq.example.runServer is false
       [java] Dec 22, 2011 5:54:42 PM org.hornetq.common.example.HornetQExample getContext
       [java] INFO: using server0/client-jndi.properties for jndi
       [java] Dec 22, 2011 5:54:43 PM org.hornetq.core.logging.impl.JULLogDelegate warn
       [java] WARNING: Tried 1 times to connect. Now giving up on reconnecting it.
       [java] javax.jms.JMSException: Failed to create session factory
       [java]     at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:615)
       [java]     at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:121)
       [java]     at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:116)
       [java]     at org.hornetq.jms.example.QueueExample.runExample(QueueExample.java:55)
       [java]     at org.hornetq.common.example.HornetQExample.run(HornetQExample.java:76)
       [java]     at org.hornetq.jms.example.QueueExample.main(QueueExample.java:35)
       [java] Caused by: HornetQException[errorCode=2 message=Cannot connect to server(s). Tried with all available servers.]
       [java]     at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:619)
       [java]     at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:611)
       [java]     ... 5 more
       [java] 
       [java] #####################
       [java] ###    FAILURE!   ###
       [java] #####################
       [java] Java Result: 1
  </code></pre>
  
  <p>The following is the hornetq-jms.xml configuration file hosted on the remote JMS server.</p>
  
  <pre><code>&lt;configuration xmlns="urn:hornetq"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd"&gt;
     &lt;!--the connection factory used by the example--&gt;
     &lt;connection-factory name="ConnectionFactory"&gt;
        &lt;connectors&gt;
           &lt;connector-ref connector-name="netty-connector"/&gt;
        &lt;/connectors&gt;
        &lt;entries&gt;
           &lt;entry name="/ConnectionFactory"/&gt;
        &lt;/entries&gt;
     &lt;/connection-factory&gt;
  
     &lt;!--the queue used by the example--&gt;
     &lt;queue name="exampleQueue"&gt;
        &lt;entry name="/queue/exampleQueue"/&gt;
     &lt;/queue&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>The following is the hornetq-configuration.xml configuration file also on the remote JMS server.</p>
  
  <pre><code>&lt;configuration xmlns="urn:hornetq"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd"&gt;
  
     &lt;!-- Connectors --&gt;
  
     &lt;connectors&gt;
        &lt;connector name="netty-connector"&gt;
           &lt;factory-class&gt;org.hornetq.core.remoting.impl.netty.NettyConnectorFactory&lt;/factory-class&gt;
           &lt;param key="host"  value="${hornetq.remoting.netty.host:localhost}"/&gt;
           &lt;param key="port"  value="${hornetq.remoting.netty.port:5445}"/&gt;
        &lt;/connector&gt;
     &lt;/connectors&gt;
  
     &lt;!-- Acceptors --&gt;
     &lt;acceptors&gt;
        &lt;acceptor name="netty-acceptor"&gt;
           &lt;factory-class&gt;org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory&lt;/factory-class&gt;        
           &lt;param key="host"  value="${hornetq.remoting.netty.host:0.0.0.0}"/&gt;
  
        &lt;/acceptor&gt;
     &lt;/acceptors&gt;
  
     &lt;!-- Other config --&gt;
  
     &lt;security-settings&gt;
        &lt;!--security for example queue--&gt;
        &lt;security-setting match="jms.queue.exampleQueue"&gt;
           &lt;permission type="createDurableQueue" roles="guest"/&gt;
           &lt;permission type="deleteDurableQueue" roles="guest"/&gt;
           &lt;permission type="createNonDurableQueue" roles="guest"/&gt;
           &lt;permission type="deleteNonDurableQueue" roles="guest"/&gt;
           &lt;permission type="consume" roles="guest"/&gt;
           &lt;permission type="send" roles="guest"/&gt;
        &lt;/security-setting&gt;
     &lt;/security-settings&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Any thoughts why the Example does not work when I try to host the queue remotely?</p>