Type: Feature Request
Status: Closed (View Workflow)
Affects Version/s: JBossAS-4.2.3.GA, JBossAS-5.0.0.CR2, JBossAS-5.0.0.GA, JBossAS-5.0.1.GA, JBossAS-5.1.0.Beta1, JBossAS-5.1.0.CR1, JBossAS-5.1.0.GA
Fix Version/s: 6.0.0.M3
Component/s: JCA service
linux/windows, jboss 4.2.3 onwards, jdk 1.5/1.6
When using jboss 4.2.3 with our app, we got an error of this sort (not exact):
Cannot Execute query.....Transaction status marked rollback
Caused by: jboss.util.NestedSQLException
Scenario when the above error happens:
a) User submits request from a web page
b) A jta transaction is started in a filter
c) From UI layer, transaction is propagated to service layer with "Propation Required" setting.
d) Service layer throws an exception (validation) and transaction is marked for rollback. Note that it is marked for rollback and not rolledback
e) The ui layer now prepares the view which requires some db queries to be executed. As soon as the first query is tried to be executed, the above exception is thrown.
I tried the above same steps with jboss 4.2.1 and it works fine. On further probing, found that in jboss 4.2.3, there was a change made as part of:
From jira links above, intention seems to be to prevent update sqls from getting exectuted when transaction is marked for rollback. But looks like the code that was added does not discriminate between read-only and update sqls and prevents even a prepared statement from getting created - WrappedConnection.checkTransactionStatus throws an exception "cannot execute query" transaction marked for rollback.
I believe that jca should discriminate between read only and update queries and should allow read only queries to go through when transaction is marked for rollback. These would allow the views to get generated in the same transaction. Ours is a 2-tier system (ui + service layer execute in the same jvm) and we are using Hibernate's recommended OpenSessionInViewPattern with one hib session+ one transaction per request.
Anyone has any thoughts about this? Is it a legitimate concern? Else, the options before us are:
a) refactor our code to have one hib session + 2 transactions (one for service layer and the other for the view). I believe even Jboss Seam does this.
b) We have a roadmap to migrate to jboss 4.2.3 followed by jboss 5.1 within next 4 months. Then we'll have to ourselves change the Wrapped connection code to discriminate between read only and update queries.