title: JMS over SSL on jBoss AS 7
body: <p>I'm trying to make my jms client work over ssl, but after configuring of jboss i have an exception </p>
  
  <blockquote>
    <p>log4j:WARN No appenders could be found for logger (org.jboss.logging).
    log4j:WARN Please initialize the log4j system properly. log4j:WARN See
    <a href="http://logging.apache.org/log4j/1.2/faq.html#noconfig" rel="nofollow">http://logging.apache.org/log4j/1.2/faq.html#noconfig</a> for more info.
    Mar 21, 2013 4:20:26 PM cz.bleble.DummyJMS
    main INFO: Attempting to acquire connection factory
    "jms/RemoteConnectionFactory" Mar 21, 2013 4:20:27 PM
    cz.bleble.DummyJMS main INFO: Found
    connection factory "jms/RemoteConnectionFactory" in JNDI Mar 21, 2013
    4:20:27 PM cz.bleble.DummyJMS main INFO:
    Attempting to acquire destination "jms/queue/Online" Mar 21, 2013
    4:20:27 PM cz.bleble.DummyJMS main INFO:
    Found destination "jms/queue/Online" in JNDI Mar 21, 2013 4:20:27 PM
    cz.bleble.DummyJMS main SEVERE: Failed to
    create session factory 15:20:27,908 INFO  [org.jboss.as.naming]
    (Remoting "esekilx5066" task-3) JBAS011806: Channel end notification
    received, closing channel Channel ID 12d4350a (inbound) of Remoting
    connection 5c0673b4 to /192.168.4.25:63316 Exception in thread
    "main" javax.jms.JMSException: Failed to create session factory
            at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:605)
            at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:119)
            at cz.bleble.DummyJMS.main(DummyJMS.java:94)
    Caused by: HornetQException[errorCode=2 message=Cannot connect to
    server(s). Tried with all available servers.]
            at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:775)
            at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:601)
            ... 2 more</p>
  </blockquote>
  
  <p>this is my client:</p>
  
  <pre><code>package cz.bleble;
  
  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 final class DummyJMS {
      private static final Logger LOG = Logger.getLogger(DummyJMS.class.getName());
  
      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/Online";
      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 = "remote://192.168.4.25:4447";
  
      public static void main(final 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("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "true");
              env.put(Context.PROVIDER_URL, System.getProperty(Context.PROVIDER_URL, PROVIDER_URL));
              env.put(Context.SECURITY_PRINCIPAL, System.getProperty("username", DEFAULT_USERNAME));
              env.put(Context.SECURITY_CREDENTIALS, System.getProperty("password", DEFAULT_PASSWORD));
              env.put("jboss.naming.client.ejb.context", true);
              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(System.getProperty("username", DEFAULT_USERNAME), System.getProperty("password", 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);
              }
  
              // Then receive the same number of messages that were sent
              for (int i = 0; i &lt; count; i++) {
                  message = (TextMessage) consumer.receive(5000);
                  LOG.info("Received message with content " + message.getText());
              }
          } catch (Exception e) {
              LOG.severe(e.getMessage());
              throw e;
          } finally {
              // closing the connection takes care of the session, producer, and consumer
              if (connection != null) {
                  connection.close();
              }
              if (context != null) {
                context.close();
              }
          }
      }
  }
  </code></pre>
  
  <p>and this are peaces of my standalone.xml from jboss</p>
  
  <pre><code>&lt;server xmlns="urn:jboss:domain:1.3"&gt;
  
      &lt;extensions&gt;
          ...
          &lt;extension module="org.jboss.as.messaging"/&gt;
          ...
      &lt;/extensions&gt;
  
      ...
  
      &lt;profile&gt;
          ...
          &lt;subsystem xmlns="urn:jboss:domain:messaging:1.2"&gt;
              &lt;hornetq-server&gt;
                  &lt;persistence-enabled&gt;true&lt;/persistence-enabled&gt;
                  &lt;security-enabled&gt;true&lt;/security-enabled&gt;
                  &lt;journal-type&gt;NIO&lt;/journal-type&gt;
                  &lt;journal-file-size&gt;102400&lt;/journal-file-size&gt;
                  &lt;journal-min-files&gt;2&lt;/journal-min-files&gt;
  
                  &lt;connectors&gt;
                      &lt;netty-connector name="netty-throughput" socket-binding="messaging-throughput"&gt;
                          &lt;param key="batch-delay" value="50"/&gt;
                      &lt;/netty-connector&gt;
                      &lt;in-vm-connector name="in-vm" server-id="0"/&gt;
                      &lt;netty-connector name="netty" socket-binding="messaging"&gt;
                        &lt;param key="ssl-enabled" value="true"/&gt;
                        &lt;param key="key-store-path" value="/keystore"/&gt;
                        &lt;param key="key-store-password" value="changeme"/&gt;
                      &lt;/netty-connector&gt;    
                  &lt;/connectors&gt;
  
                  &lt;acceptors&gt;
                      &lt;netty-acceptor name="netty-throughput" socket-binding="messaging-throughput"&gt;
                          &lt;param key="batch-delay" value="50"/&gt;
                          &lt;param key="direct-deliver" value="false"/&gt;
                      &lt;/netty-acceptor&gt;
                      &lt;in-vm-acceptor name="in-vm" server-id="0"/&gt;
                      &lt;netty-acceptor name="netty" socket-binding="messaging"&gt;
                        &lt;param key="ssl-enabled" value="true"/&gt;
                        &lt;param key="key-store-path" value="/keystore"/&gt;
                        &lt;param key="key-store-password" value="changeme"/&gt;
                        &lt;param key="trust-store-path" value="/truststore"/&gt;
                          &lt;param key="trust-store-password" value="changeme"/&gt;
                        &lt;/netty-acceptor&gt;
                  &lt;/acceptors&gt;
  
                  &lt;security-settings&gt;
                      &lt;security-setting match="#"&gt;
                          &lt;permission type="send" roles="user"/&gt;
                          &lt;permission type="consume" roles="user"/&gt;
                          &lt;permission type="createDurableQueue" roles="user"/&gt;
                          &lt;permission type="deleteDurableQueue" roles="user"/&gt;
                          &lt;permission type="createNonDurableQueue" roles="user"/&gt;
                          &lt;permission type="deleteNonDurableQueue" roles="user"/&gt;
                      &lt;/security-setting&gt;
                  &lt;/security-settings&gt;
  
                  &lt;address-settings&gt;
                      &lt;address-setting match="#"&gt;
                          &lt;dead-letter-address&gt;jms.queue.DLQ&lt;/dead-letter-address&gt;
                          &lt;expiry-address&gt;jms.queue.ExpiryQueue&lt;/expiry-address&gt;
                          &lt;redelivery-delay&gt;0&lt;/redelivery-delay&gt;
                          &lt;max-size-bytes&gt;10485760&lt;/max-size-bytes&gt;
                          &lt;address-full-policy&gt;BLOCK&lt;/address-full-policy&gt;
                          &lt;message-counter-history-day-limit&gt;10&lt;/message-counter-history-day-limit&gt;
                      &lt;/address-setting&gt;
                  &lt;/address-settings&gt;
  
                  &lt;jms-connection-factories&gt;
                      &lt;connection-factory name="InVmConnectionFactory"&gt;
                          &lt;connectors&gt;
                              &lt;connector-ref connector-name="in-vm"/&gt;
                          &lt;/connectors&gt;
                          &lt;entries&gt;
                              &lt;entry name="java:/ConnectionFactory"/&gt;
                              &lt;entry name="java:/XAConnectionFactory"/&gt;
                          &lt;/entries&gt;
                      &lt;/connection-factory&gt;
                      &lt;connection-factory name="RemoteConnectionFactory"&gt;
                          &lt;connectors&gt;
                              &lt;connector-ref connector-name="netty"/&gt;
                          &lt;/connectors&gt;
                          &lt;entries&gt;
                              &lt;entry name="java:jboss/exported/jms/RemoteConnectionFactory"/&gt;         
                          &lt;/entries&gt;
                      &lt;/connection-factory&gt;  
                      &lt;pooled-connection-factory name="hornetq-ra"&gt;
                          &lt;transaction mode="xa"/&gt;
                          &lt;connectors&gt;
                              &lt;connector-ref connector-name="in-vm"/&gt;
                          &lt;/connectors&gt;
                          &lt;entries&gt;
                              &lt;entry name="java:/JmsXA"/&gt;
                          &lt;/entries&gt;
                      &lt;/pooled-connection-factory&gt;
                  &lt;/jms-connection-factories&gt;
  
                  &lt;jms-destinations&gt;
                      &lt;jms-queue name="Online"&gt;
                          &lt;entry name="java:jboss/exported/jms/queue/Online"/&gt;
                      &lt;/jms-queue&gt;
                  &lt;/jms-destinations&gt;
              &lt;/hornetq-server&gt;
          &lt;/subsystem&gt;
          ...
      &lt;/profile&gt;
      ...
      &lt;socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}"&gt;
          ...
          &lt;socket-binding name="messaging" port="5445"/&gt;
          &lt;socket-binding name="messaging-group" port="0" multicast-address="${jboss.messaging.group.address:231.7.7.7}" multicast-port="${jboss.messaging.group.port:9876}"/&gt;
          &lt;socket-binding name="messaging-throughput" port="5455"/&gt;
          &lt;socket-binding name="osgi-http" interface="management" port="8090"/&gt;
          &lt;socket-binding name="remoting" port="4447"/&gt;
          ...
      &lt;/socket-binding-group&gt;
  
  &lt;/server&gt;
  </code></pre>
  
  <p>Does someone know what I'm doing wrong?
  I cannot find any working example of jms coonfiguration and client for jboss as7 over ssl...</p>