Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-3114

WS-RM's RMTxStore's does not recover stored sequences after restart

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.2.12, 2.3.1, 2.4
    • None
    • None
    • CXF 2.2.11 with Derby 10.6.2.1

    Description

      When WS-RM's derby storage is activated, the sequence data are persisted in the database.
      However, these sequence data are not loaded from the database when the WS-RM component is restarted.

      This problem appears to be caused by the init method of the persistence class org.apache.cxf.ws.rm.persistence.jdbc.RMTxStore which leaves an uncommitted transaction to the relevant tables open. Consequently, the next select statement that loads the persisted sequence data is not seeing the content.

      The original source code fragment of this method looks like this:

              try {
                  connection.setAutoCommit(false);
                  createTables();
              } catch (SQLException ex) {
                  LogUtils.log(LOG, Level.SEVERE, "CONNECT_EXC", ex);
                  SQLException se = ex;
                  while (se.getNextException() != null) {
                      se = se.getNextException();
                      LogUtils.log(LOG, Level.SEVERE, "CONNECT_EXC", se);
                  }
                  throw new RMStoreException(ex);
              }   
      

      The suggested change would be as follows:

              try {
                  connection.setAutoCommit(true);
                  createTables();
              } catch (SQLException ex) {
                  LogUtils.log(LOG, Level.SEVERE, "CONNECT_EXC", ex);
                  SQLException se = ex;
                  while (se.getNextException() != null) {
                      se = se.getNextException();
                      LogUtils.log(LOG, Level.SEVERE, "CONNECT_EXC", se);
                  }
                  throw new RMStoreException(ex);
              } finally {
                  try {
                      connection.setAutoCommit(false);                
                  } catch (SQLException ex) {
                      LogUtils.log(LOG, Level.SEVERE, "CONNECT_EXC", ex);
                      throw new RMStoreException(ex);
                  }
              }
      

      In the above code, the setAutoCommit(true) statement could be omitted if we simply want to rely on the default autoCommit mode.
      In any case, the suggested code makes sure that the subsequence statement is correctly executed.

      Attachments

        1. rt-ws-fixes.zip
          3 kB
          Akitoshi Yoshida

        Issue Links

          Activity

            People

              ffang Freeman Yue Fang
              ay Akitoshi Yoshida
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: