我在 WebSphere Application Server 7、JDK 1.6 和 Oracle 11g 中工作。
我在使用 ejb 时总是收到此错误。
[7/1/10 17:12:28:770 BOT] 00000013 LocalTranCoor W WLTC0033W: Resource jdbc/oraDS11 rolled back in cleanup of LocalTransactionContainment. [7/1/10 17:12:28:773 BOT] 00000013 LocalTranCoor W WLTC0032W: One or more local transaction resources were rolled back during the cleanup of a LocalTransactionContainment.
这就是我从 WAS 中的数据源获取连接的方式。
javax.sql.DataSource ds = (javax.sql.DataSource) naming.lookup("DataSource");
conn= ds.getConnection();
任何帮助将不胜感激...
最佳答案
从错误消息来看,您正在本地事务中做一些工作并且没有提交。未提交的工作在方法结束时由容器回滚(默认情况下)。
这个对 Datasource rollback in WAS6.0 的回答很好地总结了所有这些内容,由于解释它没有实际意义,我在下面引用它。
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.
我建议明确提交工作(并阅读整个答案)。
关于java - 资源 DATASOURCE 在 LocalTransactionContainment 的清理中回滚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3163636/