title: Connection from Spring Boot to artemis AMQP via SSL
body: <p>We are running on a Spring Boot project on Tomcat 9 where we need to connect to ActiveMQ Artemis via SSL. We need to have SSL in both sides. For this purpose we have created the truststores &amp; keystores for both client server as described in <a href="https://activemq.apache.org/how-do-i-use-ssl" rel="nofollow noreferrer">the documentation</a>.</p>
  <p>In the broker.xml we have the acceptor like below:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;acceptor name=&quot;netty&quot;&gt;tcp://0.0.0.0:61617?sslEnabled=true;keyStorePath=server-side-keystore.jks;keyStorePassword=secureexample;trustStorePath=server-side-truststore;trustStorePassword=secureexample;needClientAuth=true;enabledProtocols=TLSv1.2;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpDuplicateDetection=true&lt;/acceptor&gt;
  </code></pre>
  <p>In the Spring configuration we have added :</p>
  <pre class="lang-java prettyprint-override"><code>      public ConnectionFactory jmsFactory( @Value(&quot;${spring.activemq.ssl.trustStorePath}&quot;) String trustStorePath,
               @Value(&quot;${spring.activemq.ssl.trustStorePass}&quot;) String trustStorePass,
                @Value(&quot;${spring.activemq.ssl.keyStorePath}&quot;) String keyStorePath,
                @Value(&quot;${spring.activemq.ssl.keyStorePass}&quot;) String keyStorePass) {
                
              Map&lt;String, Object&gt; connectionParams = new HashMap&lt;String, Object&gt;();
              
              connectionParams.put(org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.HOST_PROP_NAME, &quot;0.0.0.0&quot;); // &lt;-- PUT THE NATTED IP HERE!
              connectionParams.put(org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.PORT_PROP_NAME, &quot;61617&quot;);
              connectionParams.put(org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.SSL_ENABLED_PROP_NAME, true);
              connectionParams.put(org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.SSL_PROVIDER, org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.OPENSSL_PROVIDER);
              
              connectionParams.put(&quot;sslEnabled&quot;, true);
              connectionParams.put(&quot;keyStorePath&quot;, keyStorePath);
              connectionParams.put(&quot;keyStorePassword&quot;,keyStorePass);
              connectionParams.put(&quot;trustStorePath&quot;,trustStorePath);
              connectionParams.put(&quot;trustStorePassword&quot;, trustStorePass);
              connectionParams.put(&quot;enabledProtocols&quot;, &quot;TLSv1.2&quot;);
             
               
              TransportConfiguration transportConfiguration = new org.apache.activemq.artemis.api.core.TransportConfiguration(&quot;org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory&quot;, connectionParams,  &quot;nettySSL&quot;);
      
              ConnectionFactory connectionFactory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, transportConfiguration);
  </code></pre>
  <p>As I am trying to deploy the project in the local Tomcat 9, this error occurs:</p>
  <pre><code>    11:50:32.989 [main] ERROR o.a.activemq.artemis.core.client - AMQ214016: Failed to create netty connection
      io.netty.channel.StacklessClosedChannelException: null
          at io.netty.channel.AbstractChannel$AbstractUnsafe.ensureOpen(ChannelPromise)(Unknown Source)
      javax.jms.JMSException: Failed to create session factory
          at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:886)
          at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:299)
          at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:294)
          at com.intrasoft.arpa.facade.config.FacadeConfiguration.jmsFactory(FacadeConfiguration.java:125)
          at com.intrasoft.arpa.facade.config.FacadeConfiguration$$EnhancerBySpringCGLIB$$b016d84a.CGLIB$jmsFactory$1(&lt;generated&gt;)
          at com.intrasoft.arpa.facade.config.FacadeConfiguration$$EnhancerBySpringCGLIB$$b016d84a$$FastClassBySpringCGLIB$$fd925062.invoke(&lt;generated&gt;)
          at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
          at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
          at com.intrasoft.arpa.facade.config.FacadeConfiguration$$EnhancerBySpringCGLIB$$b016d84a.jmsFactory(&lt;generated&gt;)
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.base/java.lang.reflect.Method.invoke(Method.java:566)
          at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
          at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
          at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1334)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524)
          at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
          at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1380)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1300)
          at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887)
          at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)
          at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:541)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1334)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524)
          at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
          at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1380)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1300)
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:657)
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
          at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1413)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524)
          at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
          at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1380)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1300)
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:657)
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
          at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1413)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524)
          at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
          at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1380)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1300)
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:657)
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
          at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1413)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524)
          at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944)
          at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
          at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144)
          at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:769)
          at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761)
          at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426)
          at org.springframework.boot.SpringApplication.run(SpringApplication.java:326)
          at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:173)
          at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:153)
          at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:95)
          at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:174)
          at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5166)
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
          at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
          at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
          at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
          at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
          at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
          at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
          at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:843)
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
          at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
          at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
          at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
          at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
          at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
          at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
          at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
          at org.apache.catalina.core.StandardService.startInternal(StandardService.java:434)
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
          at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
          at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
          at org.apache.catalina.startup.Catalina.start(Catalina.java:772)
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.base/java.lang.reflect.Method.invoke(Method.java:566)
          at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:342)
          at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:473)
      Caused by: ActiveMQNotConnectedException[errorType=NOT_CONNECTED message=AMQ219007: Cannot connect to server(s). Tried with all available servers.]
          at org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:703)
          at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:884)
          ... 120 more
      11:50:34.732 [main] ERROR o.a.activemq.artemis.core.client - AMQ214016: Failed to create netty connection
      io.netty.channel.StacklessClosedChannelException: null
          at io.netty.channel.AbstractChannel$AbstractUnsafe.ensureOpen(ChannelPromise)(Unknown Source)
      11:50:34.738 [main] ERROR o.a.activemq.artemis.core.client - AMQ214016: Failed to create netty connection
  </code></pre>
  <p>Any ideas? Does Tomcat need configuration also?</p>