weblogic jms connection oracle weblogic
<p>in my application we have configure a jms connection with weblogic 11g, and when the JAVA application read a message we see that the connection is open and closed after each message read.</p>

<p>its a probleme because the application is reading many many messages! does someone have this problem with weblogic before?</p>

<p>for this problem we decide to create a connection pool in our application by using GenericObjectPool from apache library.</p>

<p>we have win 30% of time after that. so we are proud of us.</p>

<p>but after a long time we have see that we have error with "closed connection"</p>

<pre><code>ERREUR 02004 : Impossible de créer une session JMS
    at fr.edf.mpv2.commun.message.connection.AClientJMS.getQsession(AClientJMS.java:228)
    at fr.edf.mpv2.commun.message.connection.AClientJMS.connect(AClientJMS.java:124)
    at fr.edf.mpv2.commun.message.monitor.ReceiverThread.receive(ReceiverThread.java:159)
    at fr.edf.mpv2.commun.message.monitor.ReceiverThread.run(ReceiverThread.java:66)
Caused by: oracle.jms.AQjmsException: Closed Connection
    at oracle.jms.AQjmsSession.enableEventForMsgOrder(AQjmsSession.java:6550)
    at oracle.jms.AQjmsSession.&lt;init&gt;(AQjmsSession.java:486)
    at oracle.jms.AQjmsConnection.createQueueSession(AQjmsConnection.java:657)
    at fr.edf.mpv2.commun.message.connection.AClientJMS.getQsession(AClientJMS.java:225)
    ... 3 more
Caused by: java.sql.SQLRecoverableException: Closed Connection
    at oracle.jdbc.driver.PhysicalConnection.prepareCall(PhysicalConnection.java:3645)
    at oracle.jdbc.driver.PhysicalConnection.prepareCall(PhysicalConnection.java:3606)
    at oracle.jms.AQjmsSession.enableEventForMsgOrder(AQjmsSession.java:6541)
    ... 6 more
</code></pre>

<p>and i dont know why my connection is closed. weblogic can close connection sometime and the pool is not refresh so error commin? does i need to catch this error and try to create another connection before getqueueSession?</p>

<p>thanks a lot if someone can help me on this problem. I know its was not simple to understand but if someone can help :)</p>

<p><strong>EDIT #1</strong></p>

<p>here is the xml configuration of the connection in weblogic :</p>

<pre><code>&lt;jdbc-connection-pool-params&gt;
&lt;initial-capacity&gt;10&lt;/initial-capacity&gt;
&lt;max-capacity&gt;30&lt;/max-capacity&gt;
&lt;shrink-frequency-seconds&gt;0&lt;/shrink-frequency-seconds&gt;
&lt;connection-creation-retry-frequency-seconds&gt;600&lt;/connection-creation-retry-frequency-seconds&gt;
&lt;test-frequency-seconds&gt;0&lt;/test-frequency-seconds&gt;
&lt;test-connections-on-reserve&gt;true&lt;/test-connections-on-reserve&gt;
&lt;test-table-name&gt;SQL SELECT 1 FROM T_PARAM&lt;/test-table-name&gt;
&lt;statement-cache-size&gt;10&lt;/statement-cache-size&gt;
&lt;statement-cache-type&gt;LRU&lt;/statement-cache-type&gt;
&lt;seconds-to-trust-an-idle-pool-connection&gt;0&lt;/seconds-to-trust-an-idle-pool-connection&gt;
&lt;statement-timeout&gt;30&lt;/statement-timeout&gt;
&lt;pinned-to-thread&gt;true&lt;/pinned-to-thread&gt;
</code></pre>

<p></p>

<p>the jndiname is configure in weblogic.xml</p>

<pre><code>&lt;resource-description&gt;
    &lt;res-ref-name&gt;jdbc/jmsQueuingDatasource&lt;/res-ref-name&gt;
    &lt;jndi-name&gt;jdbc/ctrnat_fco_jms&lt;/jndi-name&gt;
&lt;/resource-description&gt;
</code></pre>

<p>here is the connection with spring:</p>

<pre><code>  &lt;bean id="datasource" class="org.springframework.jndi.JndiObjectFactoryBean"   singleton="true"&gt;
    &lt;property name="jndiName" value="java:comp/env/jdbc/jmsQueuingDatasource"/&gt;
  &lt;/bean&gt;
</code></pre>

<p>i have a spring bean who get the datasource :</p>

<p>
        
    </p>

<p>DataSourceConnectionFactory containt getConnection and releaseconnection methode :</p>

<pre><code>public JmsQueueConnection getConnection() throws TechniqueException {
    LOGGER.debug("getConnection()");

    LOGGER.debug("Création d'une connexion à la queue de message.");
    JmsQueueConnection connection = new JmsQueueConnection(this.getDataSource());

    LOGGER.debug("Connexion réussie");
    return connection;

}

@Override
public void releaseConnection(JmsQueueConnection jmsQConn) throws TechniqueException {
    try {
        // on ferme simplement la connexion.
        jmsQConn.close();
    } catch (Exception e) {
        throw new TechniqueException(e);
    }
}
</code></pre>

<p>And my jms client is doing this to getConnection before getSession :</p>

<pre><code>protected JmsQueueConnection getConnection() throws TechniqueException, JMSException {
    if (this.connection == null || this.connection.isClosed()) {
        this.connection = getConnectionFactory().getConnection();
    }
    return this.connection;
}
</code></pre>

<p>i hope it can help, if you want some information</p>