title: ActiveMQ http connection refused
body: <p>I am trying to connect my java client application to ActiveMQ over http, but keep getting an error:</p>
  
  <pre><code>Failed to perform GET on: http://localhost:8080 as response was: Connection refused: connect
  </code></pre>
  
  <p>This connections works why I connect with: tcp://localhost:61616</p>
  
  <p>activemq.xml</p>
  
  <pre><code>&lt;broker&gt;
    ...
    &lt;transportConnectors&gt;
      &lt;transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;amp;wireFormat.maxFrameSize=104857600"/&gt;
      &lt;transportConnector name="http" uri="http://0.0.0.0:8080"/&gt;
    &lt;/transportConnectors&gt;
    ...
  &lt;/broker&gt;
  </code></pre>
  
  <p>jndi.properties in my Java Client program:</p>
  
  <pre><code>java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
  #java.naming.provider.url = tcp://localhost:61616
  java.naming.provider.url = http://localhost:8080
  connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
  queue.testQueue = testQueue
  </code></pre>
  
  <p>Java Client</p>
  
  <pre><code>package be.jmshub.jmsremotejndiproducer;
  
  import javax.jms.JMSException;
  import javax.jms.Connection;
  import javax.jms.MessageProducer;
  import javax.jms.Session;
  import javax.jms.Message;
  import javax.jms.Queue;
  import javax.jms.QueueConnectionFactory;
  import javax.naming.Context;
  import javax.naming.InitialContext;
  
  public class Producer {
  
      public static void main(String[] args) throws JMSException {
  
          System.out.println("JMS REMOTE PRODUCER: start");
  
          try {
              // create a new intial context, which loads from jndi.properties file
              Context ctx = new InitialContext();
              QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("connectionFactory");
              Connection connection = factory.createConnection();
              Queue queue = (javax.jms.Queue) ctx.lookup("testQueue");
              Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
  
              MessageProducer producer = session.createProducer(queue);
  
              System.out.println("JMS REMOTE PRODUCER: connected");
  
              int count = 0;
  
              for (int i = 0; i &lt; 5; i++) {
                  String messageText = "This is message " + (i + 1);
                  Message message = session.createTextMessage(messageText);
                  System.out.println("JMS REMOTE PRODUCER: sending - " + messageText);
                  producer.send(message);
                  count += 1;
              }
              System.out.println("JMS REMOTE PRODUCER: total messages sent: " + count);
  
              // Clean up
              session.close();
              connection.close();
          } catch (Exception ex) {
              System.out.println("JMS REMOTE PRODUCER: EXCEPTION:" + ex.toString());
          }
          System.out.println("JMS REMOTE PRODUCER: finished");
      }
  }
  </code></pre>
  
  <p>This works with tcp://localhost:61616 but not with <a href="http://localhost:8080" rel="nofollow">http://localhost:8080</a></p>
  
  <p>Can any person help me get this thing up and running?</p>