0 Replies Latest reply on Jun 7, 2007 7:12 AM by Michael Eibeck

    CachedConnectionManager:Closing a connection for you

    Michael Eibeck Newbie

      Hello,

      I am using a clsutered JBoss4.0.5 with EJB3 profile.
      I have defined an Oracle10 datasource.
      The datasource is defoned in the following file SDOCI-ds.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      
      <!-- ===================================================================== -->
      <!-- -->
      <!-- JBoss Server Configuration -->
      <!-- -->
      <!-- ===================================================================== -->
      
      <!-- $Id: oracle-ds.xml 23720 2004-09-15 14:37:40Z loubyansky $ -->
      <!-- ==================================================================== -->
      <!-- Datasource config for Oracle originally from Steven Coy -->
      <!-- ==================================================================== -->
      
      
      <datasources>
       <local-tx-datasource>
       <jndi-name>idmDS</jndi-name>
       <connection-url>jdbc:oracle:oci:@myDatabase</connection-url>
       <!--
      
       Here are a couple of the possible OCI configurations.
       For more information, see http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96654/toc.htm
      
       <connection-url>jdbc:oracle:oci:@youroracle-tns-name</connection-url>
       or
       <connection-url>jdbc:oracle:oci:@(description=(address=(host=youroraclehost)(protocol=tcp)(port=1521))(connect_data=(SERVICE_NAME=yourservicename)))</connection-url>
      
       Clearly, its better to have TNS set up properly.
       -->
       <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
       <user-name>user</user-name>
       <password>password</password>
       <min-pool-size>1</min-pool-size>
       <max-pool-size>20</max-pool-size>
       <idle-timeout-minutes>40</idle-timeout-minutes>
       <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
       <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
       <!-- Checks the Oracle error codes and messages for fatal errors -->
       <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
       <!-- sql to call when connection is created
       <new-connection-sql>some arbitrary sql</new-connection-sql>
       -->
      
       <!-- sql to call on an existing pooled connection when it is obtained from pool - the OracleValidConnectionChecker is prefered
       <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
       -->
      
       <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
       <metadata>
       <type-mapping>Oracle10i</type-mapping>
       </metadata>
       </local-tx-datasource>
      
      </datasources>
      


      The datasource is injected in a stateful session bean:




      Every time after I use this datasource in the login business method of the SFSB I get the following exception:

      2007-06-07 12:42:36,399 INFO [org.jboss.resource.connectionmanager.CachedConnectionManager] Closing a connection for you. Please close them yourself: org.jboss.resource.adapter.jdbc.WrappedConnection@2fc479
      java.lang.Throwable: STACKTRACE
       at org.jboss.resource.connectionmanager.CachedConnectionManager.registerConnection(CachedConnectionManager.java:290)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:417)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:842)
       at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:88)
       at ch.skyguide.aim.interfaces.businesslogic.SDOCIBusinessServiceImpl.login(Unknown Source)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
       at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      


      I do not close the underlying connection of the datasource explicitly.

      Does anyone know why this exception happens and if I should open/close connections in datasources explicitly?

      Thanks for helping.