title: Unable to lookup Remote Connection Factory of Wildfly 8.2.0 from Standalone java client Application
body: <p>I've a Queue in Wildfly 8.2.0 and deployed ear with listener. Then i'm trying to post Text Message to Remote Queue from Client program. In this scenario, unable to lookup Remote Connection Factory. Herewith attaching the program and error.</p>
  
  <p>MDB Listener on Wildfly</p>
  
  <pre><code>import javax.ejb.ActivationConfigProperty;
  import javax.ejb.MessageDriven;
  import javax.jms.JMSException;
  import javax.jms.Message;
  import javax.jms.MessageListener;
  import javax.jms.TextMessage;
  
  @MessageDriven(activationConfig = {
          @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
          @ActivationConfigProperty(propertyName = "destination", propertyValue = "jms/queue/mdbtest")})
  public class ExampleQueueMDB implements MessageListener {
  
      @Override
      public void onMessage(Message message) {
          if (message instanceof TextMessage) {
              try {
                  System.out.println("----------------");
                  System.out.println("Received: "
                          + ((TextMessage) message).getText());
                  System.out.println("----------------");
              } catch (JMSException e) {
                  e.printStackTrace();
              }
          } else {
              System.out.println("----------------");
              System.out.println("Received: " + message);
              System.out.println("----------------");
          }
      }
  
  }
  </code></pre>
  
  <p>Java Client Program</p>
  
  <pre><code>import java.util.logging.Logger;
  import java.util.Properties;
  
  import javax.jms.Connection;
  import javax.jms.ConnectionFactory;
  import javax.jms.Destination;
  import javax.jms.MessageConsumer;
  import javax.jms.MessageProducer;
  import javax.jms.Session;
  import javax.jms.TextMessage;
  import javax.naming.Context;
  import javax.naming.InitialContext;
  
  public class HelloWorldJMSClientSample {
      private static final Logger log = Logger.getLogger(HelloWorldJMSClient.class.getName());
  
      // Set up all the default values
      private static final String DEFAULT_MESSAGE = "Hello, World!";
      private static final String DEFAULT_CONNECTION_FACTORY = "jms/RemoteConnectionFactory";
      private static final String DEFAULT_DESTINATION = "jms/queue/mdbtest";
      private static final String DEFAULT_MESSAGE_COUNT = "1";
      private static final String DEFAULT_USERNAME = "user";
      private static final String DEFAULT_PASSWORD = "pass";
      private static final String INITIAL_CONTEXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";
      //private static final String PROVIDER_URL = "http-remoting://localhost:8080";
      private static final String PROVIDER_URL = "http-remoting://localhost:8080";
  
      public static void main(String[] args) throws Exception {
  
          ConnectionFactory connectionFactory = null;
          Connection connection = null;
          Session session = null;
          MessageProducer producer = null;
          MessageConsumer consumer = null;
          Destination destination = null;
          TextMessage message = null;
          Context context = null;
  
          try {
              // Set up the context for the JNDI lookup
              final Properties env = new Properties();
              env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
              env.put(Context.PROVIDER_URL, PROVIDER_URL);
              env.put(Context.SECURITY_PRINCIPAL, DEFAULT_USERNAME);
              env.put(Context.SECURITY_CREDENTIALS, DEFAULT_PASSWORD);
  
          env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
              context = new InitialContext(env);
  
              // Perform the JNDI lookups
              String connectionFactoryString = System.getProperty("connection.factory", DEFAULT_CONNECTION_FACTORY);
              log.info("Attempting to acquire connection factory \"" + connectionFactoryString + "\"");
              connectionFactory = (ConnectionFactory) context.lookup(connectionFactoryString);
              log.info("Found connection factory \"" + connectionFactoryString + "\" in JNDI");
  
              String destinationString = System.getProperty("destination", DEFAULT_DESTINATION);
              log.info("Attempting to acquire destination \"" + destinationString + "\"");
              destination = (Destination) context.lookup(destinationString);
              log.info("Found destination \"" + destinationString + "\" in JNDI");
  
              // Create the JMS connection, session, producer, and consumer
              connection = connectionFactory.createConnection(DEFAULT_USERNAME,DEFAULT_PASSWORD);
              session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
              producer = session.createProducer(destination);
             // consumer = session.createConsumer(destination);
              connection.start();
  
              int count = Integer.parseInt(System.getProperty("message.count", DEFAULT_MESSAGE_COUNT));
              String content = System.getProperty("message.content", DEFAULT_MESSAGE);
  
              log.info("Sending " + count + " messages with content: " + content);
  
              // Send the specified number of messages
              for (int i = 0; i &lt; count; i++) {
                  message = session.createTextMessage(content);
                  producer.send(message);
              }
  
          } catch (Exception e) {
              log.severe(e.getMessage());
              throw e;
          } finally {
              if (context != null) {
                  context.close();
              }
  
              // closing the connection takes care of the session, producer, and consumer
              if (connection != null) {
                  connection.close();
              }
          }
      }
  }
  </code></pre>
  
  <p>ERROR</p>
  
  <pre><code>SEVERE: Failed to create session factory
  Exception in thread "main" javax.jms.JMSException: Failed to create session factory
      at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:615)
      at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:121)
      at HelloWorldJMSClientSample.main(HelloWorldJMSClientSample.java:62)
  Caused by: java.lang.IllegalStateException: The following keys are invalid for configuring a connector: http-upgrade-endpoint, http-upgrade-enabled
      at org.hornetq.core.client.impl.ClientSessionFactoryImpl.checkTransportKeys(ClientSessionFactoryImpl.java:1227)
      at org.hornetq.core.client.impl.ClientSessionFactoryImpl.&lt;init&gt;(ClientSessionFactoryImpl.java:181)
      at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:589)
      at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:611)
      ... 2 more
  </code></pre>
  
  <p>Above error came while creating connection on line 62,</p>
  
  <pre><code>connection = connectionFactory.createConnection(DEFAULT_USERNAME,DEFAULT_PASSWORD);
  </code></pre>
  
  <p>I'm not sure, why this was not working. Hope this is a straight forward case. Please let me know, if there is different way to lookup RemoteConnectionFactory. Thanks.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Method 2:
  If i use below configuration, able to call any ejb methods but still throwing error for RemoteConnectionFactory lookup. </p>
  
  <pre><code>// Set up the context for the JNDI lookup
  final Properties env = new Properties();
  env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
  env.put("endpoint.name", "client-endpoint");
  env.put("remote.connections","default");
  env.put("remote.connection.default.port","8080");
  env.put("remote.connection.default.host","localhost");
  env.put("remote.connection.default.username", DEFAULT_USERNAME);
  env.put("remote.connection.default.password", DEFAULT_PASSWORD);
  env.put("org.jboss.ejb.client.scoped.context",true);
  context = new InitialContext(env);
  </code></pre>
  
  <p>Error after above change,</p>
  
  <pre><code>INFO: Attempting to acquire connection factory "jms/RemoteConnectionFactory"
  SEVERE: Receive timed out
  Exception in thread "main" javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]
      at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1317)
      at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1446)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:594)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
      at javax.naming.InitialContext.lookup(InitialContext.java:411)
      at HelloWorldJMSClientSample.main(HelloWorldJMSClientSample.java:56)
  Caused by: java.net.SocketTimeoutException: Receive timed out
      at java.net.PlainDatagramSocketImpl.receive0(Native Method)
      at java.net.AbstractPlainDatagramSocketImpl.receive(AbstractPlainDatagramSocketImpl.java:146)
      at java.net.DatagramSocket.receive(DatagramSocket.java:816)
      at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1287)
      ... 5 more
  </code></pre>
  
  <p>Error came on lookup, line 56,</p>
  
  <pre><code>connectionFactory = (ConnectionFactory) context.lookup(connectionFactoryString);
  </code></pre>
  
  <p>Please provide any solution for this problem. Thanks.</p>