0 Replies Latest reply on Sep 14, 2011 9:18 AM by Yuriy Bondaruk

    JBoss 6.1.0 and HornetQ: Cannot create session factory

    Yuriy Bondaruk Newbie

      Hi.

       

      I'm migrating our application with MDB from JBoss 6.0 to JBoss 6.1 and I get strange error.

       

      When JBoss is deploying my application in the first time (on start) then everything works fine. But when I try hot redeploy then hornetq throws this:

       

      {code}15:07:39,123 DEBUG [HornetQActivation] Setting up org.hornetq.ra.inflow.HornetQActivationSpec(ra=org.hornetq.ra.HornetQResourceAdapter@1bb0d9c destination=/queue/ZIndexBean destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=testuser password=**** maxSession=15)

      15:07:39,126 DEBUG [HornetQActivation] Using context {java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces:org.jboss.naming:org.jnp.interfaces} for org.hornetq.ra.inflow.HornetQActivationSpec(ra=org.hornetq.ra.HornetQResourceAdapter@1bb0d9c destination=/queue/ZIndexBean destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=testuser password=**** maxSession=15)

      15:07:39,127 DEBUG [HornetQActivation] Destination type defined as javax.jms.Queue

      15:07:39,128 DEBUG [HornetQActivation] Retrieving destination /queue/ZIndexBean of type javax.jms.Queue

      15:07:39,133 DEBUG [HornetQActivation] Got destination HornetQQueue[ZIndexBean] from /queue/ZIndexBean

      15:07:39,134 WARN  [HornetQActivation] Failure in HornetQ activation org.hornetq.ra.inflow.HornetQActivationSpec(ra=org.hornetq.ra.HornetQResourceAdapter@1bb0d9c destination=/queue/ZIndexBean destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=testuser password=**** maxSession=15): java.lang.IllegalStateException: Cannot create session factory, server locator is closed (maybe it has been garbage collected)

              at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:549) [:6.1.0.Final]

              at org.hornetq.ra.inflow.HornetQActivation.setupSession(HornetQActivation.java:352) [:6.1.0.Final]

              at org.hornetq.ra.inflow.HornetQActivation.setup(HornetQActivation.java:290) [:6.1.0.Final]

              at org.hornetq.ra.inflow.HornetQActivation$SetupActivation.run(HornetQActivation.java:587) [:6.1.0.Final]

              at org.jboss.resource.work.WorkWrapper.run(WorkWrapper.java:172) [:6.1.0.Final]

              at org.jboss.threads.SimpleDirectExecutor.execute(SimpleDirectExecutor.java:33) [:2.0.0.CR7]

              at org.jboss.threads.QueueExecutor.runTask(QueueExecutor.java:801) [:2.0.0.CR7]

              at org.jboss.threads.QueueExecutor.access$100(QueueExecutor.java:45) [:2.0.0.CR7]

              at org.jboss.threads.QueueExecutor$Worker.run(QueueExecutor.java:821) [:2.0.0.CR7]

              at java.lang.Thread.run(Thread.java:662) [:1.6.0_23]

              at org.jboss.threads.JBossThread.run(JBossThread.java:122) [:2.0.0.CR7]

       

      15:07:39,141 DEBUG [HornetQActivation] Tearing down org.hornetq.ra.inflow.HornetQActivationSpec(ra=org.hornetq.ra.HornetQResourceAdapter@1bb0d9c destination=/queue/ZIndexBean destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=testuser password=**** maxSession=15)

      15:07:39,142 DEBUG [HornetQActivation] Tearing down complete org.hornetq.ra.inflow.HornetQActivation(spec=org.hornetq.ra.inflow.HornetQActivationSpec mepf=org.jboss.ejb3.mdb.inflow.JBossMessageEndpointFactory active=true destination=/queue/ZIndexBean transacted=true)

      15:07:41,145 INFO  [HornetQActivation] Attempting to reconnect org.hornetq.ra.inflow.HornetQActivationSpec(ra=org.hornetq.ra.HornetQResourceAdapter@1bb0d9c destination=/queue/ZIndexBean destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=testuser password=**** maxSession=15)

      15:07:41,145 DEBUG [HornetQActivation] Setting up org.hornetq.ra.inflow.HornetQActivationSpec(ra=org.hornetq.ra.HornetQResourceAdapter@1bb0d9c destination=/queue/ZIndexBean destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=testuser password=**** maxSession=15)

      15:07:41,146 DEBUG [HornetQActivation] Using context {java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces:org.jboss.naming:org.jnp.interfaces} for org.hornetq.ra.inflow.HornetQActivationSpec(ra=org.hornetq.ra.HornetQResourceAdapter@1bb0d9c destination=/queue/ZIndexBean destinat

      ionType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=testuser password=**** maxSession=15)

      15:07:41,148 DEBUG [HornetQActivation] Destination type defined as javax.jms.Queue

      15:07:41,150 DEBUG [HornetQActivation] Retrieving destination /queue/ZIndexBean of type javax.jms.Queue

      15:07:41,152 DEBUG [HornetQActivation] Got destination HornetQQueue[ZIndexBean] from /queue/ZIndexBean

      15:07:41,154 ERROR [HornetQActivation] Unable to reconnect org.hornetq.ra.inflow.HornetQActivationSpec(ra=org.hornetq.ra.HornetQResourceAdapter@1bb0d9c destination=/queue/ZIndexBean destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=testuser password=**** maxSession=15): java.lang.IllegalStateException: Cannot create session factory, server locator is closed (maybe it has been garbage collected)

              at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:549) [:6.1.0.Final]

              at org.hornetq.ra.inflow.HornetQActivation.setupSession(HornetQActivation.java:352) [:6.1.0.Final]

              at org.hornetq.ra.inflow.HornetQActivation.setup(HornetQActivation.java:290) [:6.1.0.Final]

              at org.hornetq.ra.inflow.HornetQActivation.handleFailure(HornetQActivation.java:548) [:6.1.0.Final]

              at org.hornetq.ra.inflow.HornetQActivation$SetupActivation.run(HornetQActivation.java:591) [:6.1.0.Final]

              at org.jboss.resource.work.WorkWrapper.run(WorkWrapper.java:172) [:6.1.0.Final]

              at org.jboss.threads.SimpleDirectExecutor.execute(SimpleDirectExecutor.java:33) [:2.0.0.CR7]

              at org.jboss.threads.QueueExecutor.runTask(QueueExecutor.java:801) [:2.0.0.CR7]

              at org.jboss.threads.QueueExecutor.access$100(QueueExecutor.java:45) [:2.0.0.CR7]

              at org.jboss.threads.QueueExecutor$Worker.run(QueueExecutor.java:821) [:2.0.0.CR7]

              at java.lang.Thread.run(Thread.java:662) [:1.6.0_23]

              at org.jboss.threads.JBossThread.run(JBossThread.java:122) [:2.0.0.CR7]

       

      15:07:41,157 DEBUG [HornetQActivation] Tearing down org.hornetq.ra.inflow.HornetQActivationSpec(ra=org.hornetq.ra.HornetQResourceAdapter@1bb0d9c destination=/queue/ZIndexBean destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=testuser password=**** maxSession=15)

      15:07:41,158 DEBUG [HornetQActivation] Tearing down complete org.hornetq.ra.inflow.HornetQActivation(spec=org.hornetq.ra.inflow.HornetQActivationSpec mepf=org.jboss.ejb3.mdb.inflow.JBossMessageEndpointFactory active=true destination=/queue/ZIndexBean transacted=true){code}

       

      HornetQ tries to reconnect 10 times without success and each time it throws the error listed above.

      It doesn't apper on JBoss 6.0.0 Final.

       

      ZIndexBean.java

      {code}@MessageDriven(activationConfig = {

        @ActivationConfigProperty(propertyName="destinationType",

          propertyValue="javax.jms.Queue"),

        @ActivationConfigProperty(propertyName="destination",

          propertyValue="/queue/ZIndexBean"),

        @ActivationConfigProperty(propertyName="providerAdapterJNDI",

          propertyValue="java:/ZertJMSProvider"),

        @ActivationConfigProperty(propertyName="user",

          propertyValue="testuser"),

        @ActivationConfigProperty(propertyName="password",

          propertyValue="testpassword"),

        @ActivationConfigProperty(propertyName="useDLQ",

          propertyValue="true"),

        @ActivationConfigProperty(propertyName="dLQJNDIName",

          propertyValue="/queue/DLQ")

      })

       

      @TransactionManagement(TransactionManagementType.CONTAINER)

      @Depends ({"org.hornetq:module=JMS,name=\"ZIndexBean\",type=Queue"})

      @SecurityDomain("zert")

      @RunAs("administrator")

      @ResourceAdapter("jms-ra.rar")

      public class ZIndexBean implements MessageListener {

       

        @Override

        @TransactionAttribute(TransactionAttributeType.REQUIRED) 

        public void onMessage(Message message) {

          System.out.println("Message received");

        }

      }{code}

       

      hornetq-jms.xml

      {code:xml}<configuration xmlns="urn:hornetq"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                  xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">

       

         <queue name="ZIndexBean">

            <entry name="/queue/ZIndexBean"/>

         </queue>

      </configuration>{code}

       

      hornetq-configuration.xml

      {code:xml}<configuration xmlns="urn:hornetq"

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

                     xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">

       

         <bindings-directory>${jboss.server.data.dir}/hornetq/bindings</bindings-directory>

         <journal-directory>${jboss.server.data.dir}/hornetq/journal</journal-directory>

         <large-messages-directory>${jboss.server.data.dir}/hornetq/largemessages</large-messages-directory>

         <paging-directory>${jboss.server.data.dir}/hornetq/paging</paging-directory>

       

         <!-- Acceptors -->

         <acceptors>

            <!-- In VM acceptor -->

            <acceptor name="in-vm">

               <factory-class>org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory</factory-class>

               <param key="server-id" value="0"/>

            </acceptor>

       

            <!-- Netty TCP Acceptor -->

            <acceptor name="netty">

               <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>

               <param key="host" value="${hornetq.remoting.netty.host:localhost}"/>

               <param key="port" value="${hornetq.remoting.netty.port:5445}"/>

            </acceptor>

         </acceptors>

       

         <connectors>

            <connector name="netty">

               <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>

      <!--     <param key="host"  value="${jboss.bind.address:localhost}"/>-->

               <param key="host"  value="${hornetq.remoting.host:localhost}"/>

               <param key="port"  value="${hornetq.remoting.netty.port:5445}"/>

            </connector>

       

            <connector name="netty-throughput">

               <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>

      <!--     <param key="host"  value="${jboss.bind.address:localhost}"/>-->

               <param key="host"  value="${hornetq.remoting.host:localhost}"/>

       

               <param key="port"  value="${hornetq.remoting.netty.batch.port:5455}"/>

               <param key="batch-delay" value="50"/>

            </connector>

       

            <connector name="in-vm">

               <factory-class>org.hornetq.core.remoting.impl.invm.InVMConnectorFactory</factory-class>

               <param key="server-id" value="${hornetq.server-id:0}"/>

            </connector>

       

         </connectors>

       

          <security-settings>

            <!-- Use ONLY comma (',') char (without spaces) in list of roles

                 See org.hornetq.core.deployers.impl.FileConfigurationParser (it doesn't trim spaces)   -->

            <security-setting match="jms.queue.ZIndexBean">

               <permission type="createNonDurableQueue" roles="administrator,producer,consumer"/>

               <permission type="deleteNonDurableQueue" roles="administrator,producer,consumer"/>

               <permission type="consume" roles="administrator,producer,consumer"/>

               <permission type="send" roles="administrator,producer,consumer"/>

            </security-setting>

       

            <security-setting match="#">

               <permission type="createNonDurableQueue" roles="guest"/>

               <permission type="deleteNonDurableQueue" roles="guest"/>

               <permission type="consume" roles="guest"/>

               <permission type="send" roles="guest"/>

            </security-setting>

         </security-settings>

       

         <address-settings>

            <!--default for catch all-->

            <address-setting match="#">

               <dead-letter-address>jms.queue.DLQ</dead-letter-address>

               <expiry-address>jms.queue.ExpiryQueue</expiry-address>

               <max-delivery-attempts>3</max-delivery-attempts>

               <redelivery-delay>5000</redelivery-delay>

               <max-size-bytes>10485760</max-size-bytes>

               <page-size-bytes>1048576</page-size-bytes>

               <address-full-policy>PAGE</address-full-policy>

            </address-setting>

         </address-settings>

      </configuration>{code}

       

      hornetq-jboss-beans.xml

      {code:xml}<?xml version="1.0" encoding="UTF-8"?>

      <deployment xmlns="urn:jboss:bean-deployer:2.0">

       

         <!-- MBean server -->

         <bean name="MBeanServer" class="javax.management.MBeanServer">

            <constructor factoryClass="org.jboss.mx.util.MBeanServerLocator"

                         factoryMethod="locateJBoss"/>

         </bean>

       

         <!-- The core configuration -->

         <bean name="Configuration" class="org.hornetq.core.config.impl.FileConfiguration">

            <property name="configurationUrl">${jboss.server.home.url}/deploy/hornetq/hornetq-configuration.xml</property>

         </bean>

       

          <!-- The security manager -->

         <bean name="HornetQSecurityManager" class="org.hornetq.integration.jboss.security.JBossASSecurityManager">

            <start ignored="true"/>

            <stop ignored="true"/>

            <depends>JBossSecurityJNDIContextEstablishment</depends>

                  <depends>jboss.security:service=XMLLoginConfig</depends>

              <depends>jboss.security:service=JaasSecurityManager</depends>

            <property name="allowClientLogin">false</property>

            <property name="authoriseOnClientLogin">false</property>

            <property name="securityDomainName">java:/jaas/zert</property>

        </bean>

       

          <!-- The core server -->

         <bean name="HornetQServer" class="org.hornetq.core.server.impl.HornetQServerImpl">

            <constructor>

               <parameter>

                  <inject bean="Configuration"/>

               </parameter>

               <parameter>

                  <inject bean="MBeanServer"/>

               </parameter>

               <parameter>

                  <inject bean="HornetQSecurityManager"/>

               </parameter>       

            </constructor>

            <start ignored="true"/>

            <stop ignored="true"/>         

         </bean>

       

         <!-- The JMS server -->

         <bean name="JMSServerManager" class="org.hornetq.jms.server.impl.JMSServerManagerImpl">

            <constructor>        

               <parameter>

                  <inject bean="HornetQServer"/>

               </parameter>        

            </constructor>

         </bean>

       

         <!-- POJO which ensures HornetQ Resource Adapter is stopped before HornetQServer -->

         <bean name="HornetQRAService" class="org.hornetq.ra.HornetQRAService">

            <constructor>

               <parameter>

                  <inject bean="MBeanServer"/>

               </parameter>

               <parameter>jboss.jca:name='jms-ra.rar',service=RARDeployment</parameter>

            </constructor>

            <depends>HornetQServer</depends>

         </bean>

      </deployment>{code}

       

      login-config.xml

      {code:xml}  <application-policy name="zert">

          <authentication>

            <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"

              flag="required">

              <module-option name = "unauthenticatedIdentity">guest</module-option>

              <module-option name="usersProperties">props/zert-users.properties</module-option>

              <module-option name="rolesProperties">props/zert-roles.properties</module-option>

            </login-module>

          </authentication>

        </application-policy>{code}

       

      What's wrong with my configuration and how to fix it?

       

      I have prepared a small example how to reproduce this (see attachment).