Migrating to Servlet 2.3 results in, "javax.servlet.ServletException: LocalTransaction rolled-back due to setRollbackOnly"
 Technote (troubleshooting)
 
Problem(Abstract)
You are migrating an application from a Java™ 2 Platform, Enterprise Edition, V1.2 (J2EE) application that was designed for IBM® WebSphere® Application Server V3.5 or V4.0 (all releases) to a J2EE 1.3 or 1.4 application (with Servlet 2.3 or Servlet 2.4) in WebSphere Application Server V5.0 or V6.0 (all releases). After the migration, the following exception may be thrown:
javax.servlet.ServletException: LocalTransaction rolled-back due to setRollbackOnly
 
Cause
The cause of the problem is that the Servlet 2.3 and 2.4 specifications require that all dangling resources (for example, database or other backend connections) are closed when the Servlet service method is exited. Therefore, if the application has a transaction that spans multiple Servlet requests, and keeps a connection open, WebSphere Application Server will rollback the local transaction and the following exception will be thrown:

javax.servlet.ServletException: LocalTransaction rolled-back due to setRollbackOnly
at
com.ibm.ws.webcontainer.webapp.WebAppTransactionCollaborator.postInvok (WebAppTransactionCollaborator.java:224)
at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:671)
...

It is accompanied by:

WLTC0033E: Resource {0} rolled back in cleanup of unresolved LocalTransactionContainment.

and:

WLTC0032E: One or more resources rolled back. An unresolved LocalTransactionContainment had an unresolved action of rollback.

 
Resolving the problem
There are two ways to resolve the problem:
  1. Re-design the application so that it does not keep connections open through multiple Servlet requests.
  2. Package the Web application as Servlet 2.2. The Servlet 2.2 specification does not require that dangling resources be closed when exiting the Servlet service. The Servlet 2.2 .war file can be packaged in a J2EE 1.3 application .ear file.

You can also alter the behavior of the Web container when the resources, in a local transaction, are left uncommitted by the application. The following steps will walk through this process:
  1. Open the Web module in the Application Assembly Tool, Application Server Toolkit, WebSphere Studio Application Developer, Rational Application Developer or another development tool.
  2. Select the Web component and the IBM Extensions tab.
  3. The Unresolved action can be set to Rollback or Commit. The default value is Rollback. Changing it to Commit will force the Web container to commit the transaction rather than roll it back. This may be appropriate depending on the application.
 
 
Cross Reference information
Segment Product Component Platform Version Edition
Application Servers WebSphere Application Server Enterprise Migration Multi-Platform 5.0, 5.0.0, 5.0.1, 5.0.2, 5.0.2.2, 5.0.3 Enterprise
Application Servers Runtimes for Java Technology Java SDK
 
 


Document Information


Product categories: Software > Application Servers > Distributed Application & Web Servers > WebSphere Application Server > Java Transaction Service (JTS)
Operating system(s): Windows
Software version: 6.1
Software edition:
Reference #: 1141640
IBM Group: Software Group
Modified date: Aug 23, 2007