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

                 Key: CXF-3114
                 URL: https://issues.apache.org/jira/browse/CXF-3114
             Project: CXF
          Issue Type: Bug
         Environment: CXF 2.2.11 with Derby 10.6.2.1
            Reporter: Aki Yoshida


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:
{code}
        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);
        }   
{code}

The suggested change would be as follows:
{code}
        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);
            }
        }
{code}

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.




-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to