2 Replies Latest reply on May 5, 2004 9:22 AM by nico1as

    "java.sql.SQLException : Not in a transaction" when using CM

    nico1as Newbie

      Hi All,

      every 10 min, my application get datas from a database and copy them in my main database.
      For this, I use 2 CMPs with 2 xa-datasources.

      But sometime, when I use the finder to get datas from the first database, I get this exception :
      java.sql.SQLException : Not in a transaction

      It's not a blocking error but I'm curious to know what does it mean ?
      Maybe, there's a problem in my application configuration ?

      I use JBOSS 3.2.4RC1 with oracle 8.1.7.4.

      Thank you for your help.

      Nicolas.



      My log file :

      [2004-05-05 11:51:22,750] [Thread-44] [org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.InterfaceClientsOut0#findAll] [DEBUG] : Executing SQL: SELECT t0_c.Id_DC_Client FROM INTERFACE_CLIENTS_OUT t0_c

      [2004-05-05 11:51:22,750] [Thread-44] [org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory] [WARN] : Destroying connection that is not valid, due to the following exception:

      java.sql.SQLException: Not in a transaction

      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:169)

      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:211)

      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:274)

      at oracle.jdbc.driver.OracleConnection.needLine(OracleConnection.java:1630)

      at oracle.jdbc.driver.OracleStatement.(OracleStatement.java:440)

      at oracle.jdbc.driver.OracleConnection.privateCreateStatement(OracleConnection.java:477)

      at oracle.jdbc.driver.OracleConnection.createStatement(OracleConnection.java:386)

      at org.jboss.resource.adapter.jdbc.CheckValidConnectionSQL.isValidConnection(CheckValidConnectionSQL.java:27)

      at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnectionFactory.isValidConnection(BaseWrapperManagedConnectionFactory.java:436)

      at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.checkValid(BaseWrapperManagedConnection.java:265)
      ......


      My EJB Session Method :

      
       /**
       * Recupere les demandes commerciales dans les differentes BD externes. <BR>
       *
       * @ejb.interface-method
       *
       *@param idUserSession identifiant de la session utilisateur
       *@exception MagesException Description of the Exception
       */
       public void getCommercialRequests(Integer idUserSession, Integer time_out) throws MagesException
       {
       logger.methodIn("getCommercialRequest");
      
       String[] externalDbNames = PropertiesManager.getMultiValuedGeneralParameter(PropertiesNames.GeneralParameter.EXTERNAL_DB_NAMES);
       FollowUpRowGetter rowGetter = null;
       int timeout = 0;
      
       if (time_out != null)
       {
       timeout = time_out.intValue();
       }
      
       for (int i = 0; i < externalDbNames.length; i++) {
       try
       {
       logger.debug("[trans] ==> migration des dc pour la base ["+i+"]");
       Iterator subscriberIterator = ((InterfaceClientsOutHome) (ConnectionManager.get().ejbLookUp(sessionContext, JndiNames.INTERFACE_CLIENTS_OUT+i, InterfaceClientsOutHome.class))).findAll().iterator();
       logger.debug("Itérateur sur subscriber. Y a-t-il des enregistrements ? "+subscriberIterator.hasNext());
      
       while(subscriberIterator.hasNext())
       {
       try
       {
       rowGetter = ((FollowUpRowGetterHome) (ConnectionManager.get().ejbLookUp(sessionContext, JndiNames.FOLLOWUPROWGETTER, FollowUpRowGetterHome.class))).create();
      
       if(null == rowGetter)
       throw new MagesException("Migration des dc NON effectuée : impossible de créer le bean FollowUpRowGetterBean = [null]");
      
      
       rowGetter.getCommercialRequestSubscriber(((InterfaceClientsOut) PortableRemoteObject.narrow(subscriberIterator.next(),InterfaceClientsOut.class)).getHandle(), timeout);
      
       }
       catch(CreateException e)
       {
       logger.warn("getCommercialRequests() : migration ANNULEE pour subscriber db ["+i+"]", e);
       }
       catch(RemoteException e)
       {
       logger.warn("getCommercialRequests() : migration ANNULEE pour subscriber db ["+i+"]", e);
       }
       }
      
       } catch (FinderException e) {
       logger.warn("getCommercialRequests() : erreur dans la Recherche des dc pour la db ["+i+"]. On ne peut traiter AUCUN subscriber.", e);
       } catch (RemoteException e) {
       logger.warn("getCommercialRequests() : erreur dans l'Itérateur des dc pour la db ["+i+"]. On ne peut traiter AUCUN subscriber supplémentaire.", e);
       } catch (MagesException e) {
       logger.warn("getCommercialRequests() : migration des dc 'subscriber' NON terminée pour la db ["+i+"]", e);
       } finally {
       logger.debug("[trans] <== migration des dc pour la base ["+i+"]");
       }
       }
      
       }
      
      




      The two datasource definitions :


      
      <datasources>
       <xa-datasource>
       <jndi-name>MagesXaDS</jndi-name>
       <track-connection-by-tx>true</track-connection-by-tx>
       <isSameRM-override-value>false</isSameRM-override-value>
       <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
       <xa-datasource-property name="URL">jdbc:oracle:thin:@152.65.45.51:1521:APPDEV</xa-datasource-property>
       <xa-datasource-property name="User">admin</xa-datasource-property>
       <xa-datasource-property name="Password">apps</xa-datasource-property>
       <!-- 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>
       <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
       <no-tx-separate-pools/>
       </xa-datasource>
      
       <xa-datasource>
      
      
       <jndi-name>ExternalDbOracleXaDS0</jndi-name>
      
       <track-connection-by-tx>true</track-connection-by-tx>
       <isSameRM-override-value>false</isSameRM-override-value>
       <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
      
      
       <xa-datasource-property name="URL">jdbc:oracle:thin:@152.56.102.185:1521:I8I</xa-datasource-property>
      
       <xa-datasource-property name="User">user</xa-datasource-property>
       <xa-datasource-property name="Password">pass</xa-datasource-property>
       <!-- 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>
       <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
       <no-tx-separate-pools/>
      
       <!-- sql to call on an existing pooled connection when it is obtained from pool - the OracleValidConnectionChecker is prefered -->
       <check-valid-connection-sql>SELECT COUNT(*) FROM DUAL</check-valid-connection-sql>
      
       <idle-timeout-minutes>15</idle-timeout-minutes>
      
       </xa-datasource>
      
      
      
       <mbean code="org.jboss.resource.adapter.jdbc.xa.oracle.OracleXAExceptionFormatter"
       name="jboss.jca:service=OracleXAExceptionFormatter">
       <depends optional-attribute-name="TransactionManagerService">jboss:service=TransactionManager</depends>
       </mbean>
      
      </datasources>