title: JMS client to ActiveMQ at server on Red Hat JBoss EAP 7.3 in Java
body: <p>I am writing a Java client to connect to my JBoss EAP 7.3 server running ActiveMQ, and I am getting various connection responses as I alter the parameters.  Please help me correct the parameters/code.  I get:</p>
  <pre><code>09:46:57.227 [main] INFO org.xnio.nio - XNIO NIO Implementation Version 3.4.6.Final
  09:46:57.606 [Remoting &quot;config-based-naming-client-endpoint&quot; I/O-1] DEBUG org.xnio.nio - Started channel thread 'Remoting &quot;config-based-naming-client-endpoint&quot; I/O-1', selector sun.nio.ch.WindowsSelectorImpl@17ab1d7e                                 ...
  jboss.naming.client.connect.options. has the following options {}
  09:46:57.763 [main] DEBUG org.jboss.naming.remote.client.HaRemoteNamingStore - Failed to connect to server http-remoting://127.0.0.1:8080
  java.lang.RuntimeException: java.io.IOException: For now upgrade responses must have a content length of zero.
      at org.jboss.naming.remote.protocol.IoFutureHelper.get(IoFutureHelper.java:95)
      at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:198)
  ...    at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:146)
      at javax.naming.InitialContext.lookup(InitialContext.java:417)
      at com.goprecise.ams.demo.SendJmsToProcess.main(SendJmsToProcess.java:46)
  Caused by: java.io.IOException: For now upgrade responses must have a content length of zero.
  ...     at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
      at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89)
      at org.xnio.nio.WorkerThread.run(WorkerThread.java:571)
  ...     at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:335)
      at org.jboss.naming.remote.client.EndpointCache$EndpointWrapper.connect(EndpointCache.java:122)
      at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:197)
      ... 8 common frames omitted
  javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [http-remoting://127.0.0.1:8080 (java.io.IOException: For now upgrade responses must have a content length of zero.)]
      at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:244)
      at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:149)
  </code></pre>
  <p>This is the Java client code in a try catch block attempting to connect:</p>
  <pre class="lang-java prettyprint-override"><code>            Properties env = new Properties();
              env.put(Context.INITIAL_CONTEXT_FACTORY, &quot;org.jboss.naming.remote.client.InitialContextFactory&quot;);
              env.put(Context.PROVIDER_URL, &quot;http-remoting://127.0.0.1:8080&quot;);  
              env.put(Context.SECURITY_PRINCIPAL,adminUser);
              env.put(Context.SECURITY_CREDENTIALS, adminPassword);
              Context  namingContext = new InitialContext(env);
  
              String CONNECTION_FACTORY = &quot;java:jboss/exported/jms/RemoteConnectionFactory&quot;; 
                          ConnectionFactory connectionFactory = (ConnectionFactory) namingContext.lookup(CONNECTION_FACTORY);
              System.out.println(&quot;Got ConnectionFactory&quot;);
  
              Destination destination = (Destination) namingContext.lookup(QUEUE);  // Sure QUEUE is correct
              System.out.println(&quot;Got JMS Endpoint &quot; + QUEUE);
  
              JMSContext context = connectionFactory.createContext(adminUser, adminPassword);
              context.createProducer().send(destination, xmlContent);
              System.out.println(&quot;Got JMS destination&quot;);
  
  </code></pre>
  <p>And these are my JNDI tree values in the EAP management console for java:jboss/exported &gt;&gt; JMS &gt;&gt;</p>
  <pre><code>URI                    java:jboss/exported/jms/RemoteConnectionFactory
  Class Name             org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory
  Value                  ActiveMQConnectionFactory [serverLocator=ServerLocatorImpl 
                         [initialConnectors=[TransportConfiguration(name=http-connector, 
                         factory=org-apache-activemq-artemis-core-remoting-impl-netty-
                         NettyConnectorFactory) ?httpUpgradeEndpoint=http-                    
                         acceptor&amp;activemqServerName=default&amp;httpUpgradeEnabled=true&amp;port=
                         8080&amp;host=kubernetes-docker-internal], discoveryGroupConfiguration=null], 
                         clientID=null, consumerWindowSize = 1048576, dupsOKBatchSize=1048576, 
                         transactionBatchSize=1048576, readOnly=falseEnableSharedClientID=true]
  </code></pre>