1 Reply Latest reply on Oct 30, 2014 5:03 AM by Andy Taylor

    Create a connection to an SSL enabled hornetQ server

    Anuja Khemka Newbie

      I have written a hornetQ client using JNDI. Now the hornetQ server is SSL enabled but I cannot connect to it. Please find my config file below and tell me what I am missing. We are using JNP for naming purposes.

       

      <?xml version="1.0" encoding="UTF-8"?>

      <beans xmlns="http://www.springframework.org/schema/beans"

        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jms="http://www.springframework.org/schema/jms"

        xmlns:tx="http://www.springframework.org/schema/tx"

        xsi:schemaLocation="http://www.springframework.org/schema/beans

        http://www.springframework.org/schema/beans/spring-beans.xsd

        http://www.springframework.org/schema/tx

        http://www.springframework.org/schema/tx/spring-tx.xsd

        http://www.springframework.org/schema/context

        http://www.springframework.org/schema/context/spring-context.xsd

        http://www.springframework.org/schema/jms

        http://www.springframework.org/schema/jms/spring-jms.xsd">

        <!-- import resource="classpath:spring-common.xml" /-->

        <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

        <property name="locations">

        <list>

        <value>classpath:jndi.properties</value>

        </list>

        </property>

        </bean>

       

        <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">

        <property name="environment">

        <props>

        <prop key="java.naming.provider.url">${java.naming.provider.url}</prop>

        <prop key="java.naming.factory.initial">${java.naming.factory.initial}</prop>

        <prop key="java.naming.factory.url.pkgs">${java.naming.factory.url.pkgs}</prop>

        <prop key="jboss.naming.client.remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED">${ssl.enabled}</prop>

        <prop key="jboss.naming.client.connect.options.org.xnio.Options.SSL_STARTTLS">${ssl.starttls}</prop>

        </props>

        </property>

        </bean>

       

        <bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">

              <property name="jndiTemplate" ref ="jndiTemplate"/>

              <property name="jndiName" value="ConnectionFactory"/>

          </bean>

       

          <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">

              <property name="connectionFactory" ref="connectionFactory"/>

              <property name="defaultDestination" ref="destination"/>

              <property name="pubSubDomain" value="true"/>

              <property name="deliveryPersistent" value="true"/>

              <property name="deliveryMode" value="2"/>

          </bean>

        

          <bean id="destination" class="org.springframework.jndi.JndiObjectFactoryBean">

              <property name="jndiTemplate" ref="jndiTemplate"/>

              <property name="jndiName" value="ACS_BOOT"/>

          </bean>

        

          <!-- Listener Asynchronous -->

          <bean id="acsBootListener" class="com.viasat.nbn.nms.acsjmssubscriber.AcsBootListener"/>

       

          <jms:listener-container concurrency="5-10">

                       <jms:listener destination="ACS_BOOT" ref="acsBootListener"/>

          </jms:listener-container>

       

      </beans>

       

      And my Main class looks like this:

       

       

         public class AcsBootConsumer {

        private String keyStore, ksPassword, trustStore, tsPassword;

       

       

        public static void main(String[] args) throws JMSException{

        ApplicationContext context = new ClassPathXmlApplicationContext("spring-cred.xml");

        AcsBootConsumer acsBootConsumer = (AcsBootConsumer)context.getBean("acsBootConsumer");

        System.setProperty("javax.net.ssl.keyStore",acsBootConsumer.keyStore);

        System.setProperty("javax.net.ssl.keyStorePassword", acsBootConsumer.ksPassword);

        System.setProperty("javax.net.ssl.trustStore",acsBootConsumer.trustStore);

        System.setProperty("javax.net.ssl.trustStorePassword", acsBootConsumer.tsPassword);

        ClassPathXmlApplicationContext context1 = new ClassPathXmlApplicationContext("spring-app.xml");

        JndiTemplate jndiTemplate = (JndiTemplate)context1.getBean("jndiTemplate");

        System.out.println("AcsBootConsumer connected to " + jndiTemplate.getEnvironment().getProperty("java.naming.provider.url"));

        }

       

       

      I just cannot understand where am I going wrong. I get the following error:

       

       

      SEVERE: Could not refresh JMS Connection for destination 'ACS_BOOT' - retrying in 5000 ms. Cause: Failed to create session factory; nested exception is HornetQException[errorType=NOT_CONNECTED message=HQ119007: Cannot connect to server(s). Tried with all available servers.]