Resource DATASOURCE rolled back in cleanup of LocalTransactionContainment

不问归期 提交于 2019-12-04 09:29:55

From the error message, you are doing some work inside a local transaction and not committing it. The uncommitted work gets rolledback by the container at the end of the method (by default).

This answer to Datasource rollback in WAS6.0 summarizes all this pretty well and since there is no real point at paraphrasing it, I'm quoting it below.

A LocalTransactionContainment is what you get in the absence of a global (XA) transaction. The message indicates that you performed some local transaction work as part of that containment scope (method or activity session) and then did not commit. The default behaviour (controlled by unresolved-action) is to rollback any uncommited work at the end of the scope. You have a number of options:

  • Explicitly commit the local transaction

    connection.commit(); // after the work has been performed
    
  • Change the data source to use auto-commit

    connection.setAutoCommit(true); //
    

    before the connection is used

  • Place the work within a global transaction

    Context ic = new InitialContext();
    UserTransaction ut =
    (UserTransaction) ic.lookup("java:comp/UserTransaction");
    ut.begin();
    // use connection here
    ut.commit();
    
  • Change the unresolved-action to commit
    Select the 'Servlets' tab on the deployment descriptor editor and then select the servlet in question. Under 'WebSphere Extensions' and then 'Local Transaction' set the 'Unresolved Action' to 'Commit' from the drop-down menu.

I'd suggest committing the work explicitly (and reading the whole answer).

This exception occurs when table get locked, so you have locked your table in database so release that lock and commit whatever changes you have done.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!