0 Replies Latest reply on May 26, 2009 5:08 AM by Ivan Larionov

    Strange JBossLocalXAException during a regular transaction

    Ivan Larionov Newbie

      Hi.

      I'm experiencing a problem, which somehow relates to distributed transactions. I'm using only one local-tx datasource inside the login method of the following session bean and anticipate it being a regular transaction (I don't even control transactions in my code as it is supposed to be CMT). As I understand my datasource is 1PC aware (Forgive me if I show crass ignorance, I'm facing such problem for the first time) why then JBoss involves XA resources in the process and tends to make the transaction 2 phase.

      Could anyone explain what is going on?

      Here how the datasource is declared:

      <local-tx-datasource>
       <jndi-name>main/jdbc/AuthDS</jndi-name>
       <connection-url>jdbc:postgresql://localhost:5432/main?schema=masterdb</connection-url>
       <driver-class>org.postgresql.Driver</driver-class>
       <user-name>masterdb</user-name>
       <password>1</password>
       <metadata>
       <type-mapping>PostgreSQL 8.0</type-mapping>
       </metadata>
       </local-tx-datasource>
      


      And here how the session bean is defined:
      @Stateless
      @Remote(LoginSession.class)
      @Local(LoginSession.class)
      @PermitAll
      public class LoginSessionBean implements LoginSession
      {
       private DataSource datasource;
       private String jndiName = "main/jdbc/AuthDS";
      ...
      public MainPrincipal login(String user, String password) throws LoginException
       {
       if (logger.isTraceEnabled())
       logger.trace("user=" + user);
       try{
       Context ctx = new InitialContext();
       datasource = (DataSource)ctx.lookup("java:"+jndiName);
       } catch(Exception e) {
       logger.warn(e, e);
       }
       Connection conn = null;
       PreparedStatement stmt = null;
       ResultSet rs = null;
       try {
       conn = datasource.getConnection();
       stmt = conn.prepareStatement(passwordQuery);
       stmt.setString(1, user);
       stmt.setString(2, DigestMessage(password));
       rs = stmt.executeQuery();
       while(rs.next()){
       if (logger.isTraceEnabled()) {
       logger.trace(rs.getString(1) + " (" + rs.getString(2) + ")");
       logger.trace("success logged in user=" + user);
       }
       return new MainPrincipal(user,password,rs.getString(3));
       }
       stmt = conn.prepareStatement(pincodeQuery);
       stmt.setString(1, user);
       stmt.setString(2, DigestMessage(password));
       rs = stmt.executeQuery();
       while(rs.next()){
       if (logger.isTraceEnabled()) {
       logger.trace(rs.getString(1) + " (" + rs.getString(2) + ")");
       logger.trace("success logged in by pincode user=" + user);
       }
       MainPrincipal principal= new MainPrincipal(user,password,rs.getString(3));
       principal.setByPin(true);
       return principal;
       }
      
       if (logger.isTraceEnabled())
       logger.trace("invalid user login attempt "+ user);
       } catch (SQLException e) {
       if (logger.isTraceEnabled())
       logger.trace(e, e);
       throw new LoginException("authentification failure. Message: " + e.getMessage());
       } finally {
       try {
       if (rs != null) rs.close();
       if (stmt != null) stmt.close();
       if (conn != null) conn.close();
       } catch (SQLException e) {
       if (logger.isTraceEnabled())
       logger.trace(e, e);
       throw new LoginException("authentification failure. Message: " + e.getMessage());
       }
       }
       return null;
       }
      ...
      }
      


      Following exception appears from time to time when users actively use the system:
      2009-05-23 09:58:25,083 WARN [org.hibernate.engine.loading.CollectionLoadContext] On CollectionLoadContext#cleanup, localLoadingCollectionKeys contained [1]
       entries
      2009-05-23 09:58:25,097 WARN [com.arjuna.ats.jta.logging.loggerI18N] [com.arjuna.ats.internal.jta.transaction.arjunacore.enliststarterror] [com.arjuna.ats.i
      nternal.jta.transaction.arjunacore.enliststarterror] TransactionImple.enlistResource - XAResource.start returned: XAException.XAER_PROTO for < 131075, 28, 26
      , 1-aab780b:85d8:4a16ffdf:7511aab780b:85d8:4a16ffdf:7514^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
      ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ >
      2009-05-23 09:58:25,098 ERROR [STDERR] org.jboss.resource.connectionmanager.JBossLocalXAException: Trying to start a new tx when old is not complete! old: <
      2009-05-23 09:58:25,098 ERROR [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager$LocalXAResource.start(TxConnectionManager.java:886)
      2009-05-23 09:58:25,098 ERROR [STDERR] at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.enlistResource(TransactionImple.java:774)
      2009-05-23 09:58:25,098 ERROR [STDERR] at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.enlistResource(TransactionImple.java:497)
      2009-05-23 09:58:25,098 ERROR [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener$TransactionSynchronization.enli
      st(TxConnectionManager.java:773)
      2009-05-23 09:58:25,098 ERROR [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.enlist(TxConnectionManager.java
      :564)
      2009-05-23 09:58:25,098 ERROR [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager.managedConnectionReconnected(TxConnectionManager.java:337
      )
      2009-05-23 09:58:25,098 ERROR [STDERR] at org.jboss.resource.connectionmanager.BaseConnectionManager2.reconnectManagedConnection(BaseConnectionManager2.java
      :518)
      2009-05-23 09:58:25,098 ERROR [STDERR] at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:399)
      2009-05-23 09:58:25,098 ERROR [STDERR] at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnecti
      onManager2.java:842)
      2009-05-23 09:58:25,098 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:88)
      2009-05-23 09:58:25,098 ERROR [STDERR] at com.avistatime.avista.security.ejb.LoginSessionBean.login(LoginSessionBean.java:101)
      


      Thanks.