<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Re: connecting a remote hornetQ server
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/anso2">andrzej sochal</a> in <i>JBoss AS 7 Development</i> - <a href="https://community.jboss.org/message/759409#759409">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>I have a similar problem. My scenario is as follows:</p><p>Messages are being sent from jboss-4.2.1.GA to a remote stand alone hornetq-2.2.14.Final.</p><p>There is an MDB deployed on jboss-7.1.1.Final node that listens to the remote stand alone hornetq-2.2.14.Final queue.</p><p>Everything seems to be working fine up to the point where there is a disconnection </p><p>between jboss 7 node and hornetq. For example, when hornetq is shut down and then brought back up, jboss</p><p>jboss 7 is not able to reconnect to hornetq. Jboss 4 on the other hand is able to send messages to hornetq but messages are not</p><p>being consumed by MDB.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This warning happens every two minutes on jboss 7 node:</p><p>&#160; </p><p>2012-09-13 07:59:26,904 WARN&#160; [com.arjuna.ats.jta] (Periodic Recovery:) ARJUNA016027: Local XARecoveryModule.xaRecovery got XA exception XAException.XAER_RMERR: javax.transaction.xa.XAException: Error</p><p> trying to connect to any providers for xa recovery</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hornetq.jms.server.recovery.HornetQXAResourceWrapper.getDelegate(HornetQXAResourceWrapper.java:275)</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hornetq.jms.server.recovery.HornetQXAResourceWrapper.recover(HornetQXAResourceWrapper.java:77)</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.xaRecovery(XARecoveryModule.java:503)</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.resourceInitiatedRecoveryForRecoveryHelpers(XARecoveryModule.java:471)</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.bottomUpRecovery(XARecoveryModule.java:385)</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.periodicWorkSecondPass(XARecoveryModule.java:166)</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.doWorkInternal(PeriodicRecovery.java:789)</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.run(PeriodicRecovery.java:371)</p><p>Caused by: java.lang.IllegalStateException: Cannot create session factory, server locator is closed (maybe it has been garbage collected)</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hornetq.core.client.impl.ServerLocatorImpl.assertOpen(ServerLocatorImpl.java:1823)</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:699)</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hornetq.jms.server.recovery.HornetQXAResourceWrapper.connect(HornetQXAResourceWrapper.java:321)</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hornetq.jms.server.recovery.HornetQXAResourceWrapper.getDelegate(HornetQXAResourceWrapper.java:251)</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; ... 7 more</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>After doing some research, I found that:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>HornetQXAResourceWrapper located in JBOSS_HOME\modules\org\hornetq\main\hornetq-jms-2.2.13.Final.jar</p><p>is trying to connect to HornetQ in this method:</p><p> public XAResource getDelegate(boolean retry){</p><p>&#160; XAResource result = null;</p><p>&#160;&#160;&#160;&#160; Exception error = null;</p><p>&#160;&#160;&#160;&#160; try</p><p>&#160;&#160;&#160;&#160; {</p><p>&#160;&#160;&#160;&#160;&#160; <strong> result = connect();</strong></p><p>&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160;&#160; catch (Exception e)</p><p>&#160;&#160;&#160;&#160; {</p><p>&#160;&#160;&#160;&#160;&#160;&#160; error = e;</p><p>&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160;&#160; ...</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p> The connect method is getting ServerLocatorImp object and calls createSessionFactory method on it</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; ... </p><p>&#160;&#160;&#160; this.serverLocator = xaRecoveryConfig.getHornetQConnectionFactory().getServerLocator();</p><p>&#160;&#160;&#160; this.serverLocator.disableFinalizeCheck();</p><p>&#160;&#160;&#160; this.csf = this.serverLocator.createSessionFactory();</p><p>&#160;&#160;&#160; ...</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The createSessionFactory method of ServerLocatorImpl (hornetq-core-2.2.13.Final) is checking for ServerLocator state.</p><p>If it is NOT null and NOT initialized then it throws this exception.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; if (state != null &amp;&amp; state != STATE.INITIALIZED)</p><p>&#160;&#160;&#160; {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; throw new IllegalStateException("Cannot create session factory, server locator is closed (maybe it has been garbage collected)");</p><p>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>When I manually change state to null, this exception is no longer thrown and the state gets initialized again.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>When there is a disconnection, it looks like state gets set to CLOSED which is triggering this exception. </p><p>Instead, shouldn't state be set to NULL on disconnect to allow for reconnections. </p><p>Is this a bug???</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/759409#759409">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss AS 7 Development at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2225">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>