Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
- 3 questions on transactions - misunderstanding or bug

- 3 questions on transactions - misunderstanding or bug

2007-08-13       - By X490812

 Back
I will give the pertinent code for 3 use cases and describe the outcomes. The
outcomes dont make sense for my understanding of EJB3.0.
the function batchRemoveEndedProcesses does a simple delete from an oracle db.
All this is in a SLSB




 | @(protected)(javax.ejb.TransactionAttributeType.REQUIRED)
 | public void cleanupEndedProcesses(String processId)
 | .
 | .
 | while (pidVec.size() > 1075)
 | {
 |   endNdx = pidVec.size() > BATCHSIZE? BATCHSIZE:pidVec.size();
 |   tmpList = new ArrayList<String>(pidVec.subList(0, endNdx));
 |   batchRemoveEndedProcesses(tmpList, jbpmDAO);
 |   cnt += endNdx;
 |   pidVec.removeAll(tmpList);
 | }
 | .
 | .
 | @(protected)(javax.ejb.TransactionAttributeType.REQUIRES_NEW)
 | private void batchRemoveEndedProcesses(List<String> pidVec, JbpmDAO jbpmDAO)
 | {
 |   try {
 |     jbpmDAO.removeEndedProcesses(pidVec);
 |   }
 |   catch (Exception e) {
 |     throw new WorkflowException(e);
 |   }
 | }
 |
 |
first call to removeEndedProcesses succeeds, second call succeeds
start: 1080 rows to be deleted
end1 removeEndedProcesses : 1080 rows to be deleted
end2 removeEndedProcesses : 1080 rows to be deleted
end: 1070 - 10 rows deleted
ISSUE:  WHY DOES THE REQUIRES_NEW FUNCTION NOT COMMIT
i UNDERSTOOD THAT WHEN YOU HAVE REUQIRES_NEW, THE FUNCTION WILL COMMIT ITS
TRANSACTION
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --


 | @(protected)(javax.ejb.TransactionAttributeType.NEVER)
 | public void cleanupEndedProcesses(String processId)
 | .
 | .
 | while (pidVec.size() > 1075)
 | {
 |   endNdx = pidVec.size() > BATCHSIZE? BATCHSIZE:pidVec.size();
 |   tmpList = new ArrayList<String>(pidVec.subList(0, endNdx));
 |   batchRemoveEndedProcesses(tmpList, jbpmDAO);
 |   cnt += endNdx;
 |   pidVec.removeAll(tmpList);
 | }
 | .
 | .
 | @(protected)(javax.ejb.TransactionAttributeType.REQUIRES_NEW)
 | private void batchRemoveEndedProcesses(List<String> pidVec, JbpmDAO jbpmDAO)
 | {
 |   try {
 |     jbpmDAO.removeEndedProcesses(pidVec);
 |     context.setRollbackOnly();
 |   }
 |   catch (Exception e) {
 |     throw new WorkflowException(e);
 |   }
 | }
 |
 |
first call to removeEndedProcesses succeeds. Whenrollback called and throws
exception
Caused by: java.lang.IllegalStateException: setRollbackOnly() not allowed
without a transaction.
start: 1080
end1 removeEndedProcesses : 1080
end: 1080
ISSUE: Why does CODE act as if REQUIRES_NEW is not there?
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --

 | @(protected)(javax.ejb.TransactionAttributeType.REQUIRED)
 | public void cleanupEndedProcesses(String processId)
 | .
 | .
 | while (pidVec.size() > 1075)
 | {
 |   endNdx = pidVec.size() > BATCHSIZE? BATCHSIZE:pidVec.size();
 |   tmpList = new ArrayList<String>(pidVec.subList(0, endNdx));
 |   batchRemoveEndedProcesses(tmpList, jbpmDAO);
 |   cnt += endNdx;
 |   pidVec.removeAll(tmpList);
 | }
 | .
 | .
 | @(protected)(javax.ejb.TransactionAttributeType.REQUIRES_NEW)
 | private void batchRemoveEndedProcesses(List<String> pidVec, JbpmDAO jbpmDAO)
 | {
 |   try {
 |     jbpmDAO.removeEndedProcesses(pidVec);
 |     context.setRollbackOnly();
 |   }
 |   catch (Exception e) {
 |     throw new WorkflowException(e);
 |   }
 | }
 |
first call removeEndedProcesses succeeds (no commit) and then does rollback
with no exception. Second call removeEndedProcesses throws esception when
getting a connection:
Caused by: javax.resource.ResourceException: Transaction is not active: tx
=TransactionImpl:XidImpl[FormatId=257, GlobalId=ro-0029aits/47, BranchQual=,
localId=47]
ISSUE: Why does rollback screw things up for the next run through the REQUIRES
_NEW function?
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --

The only way I could get above deletes to commit as I wanted (in batches) was
if the loop above was in a javax.ejb.TransactionAttributeType.NEVER function;
This should not be necessary(I thought).
In addition, for unit testing, I wanted to rollback via context.setRollbackOnly
(), and I could not get that to work ;

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic
&p=4073660#4073660

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode
=reply&p=4073660
__ ____ ____ ____ ____ ____ ____ ____ ____ ____
jboss-user mailing list
jboss-user@(protected)
https://lists.jboss.org/mailman/listinfo/jboss-user

©2008 junlu.com - Jax Systems, LLC, U.S.A.