[jboss-user] [EJB 3.0] - RollbackException and PersistentContext
vedgunjan
do-not-reply at jboss.com
Sun Apr 1 00:30:23 EDT 2007
Hi Experts,
Im using injected persistent context in my session bean.
@PersistentContext(unit="AppConext")
private EntityManeger entityManager;
In this session bean i've a method in which,i iterate over the list.
Lets say this method as method1();
The scenario is somthing like this..
@TransactionAttribute(REQUIRES_NEW)
public voic method1()
{
......some code.....
for(SomeObject obj : someObjectList)
{
..............some code....
//call method2
method2(obj);
.........some code......
}
}
@TransactionAttribute(REQUIRES_NEW)
public void method2()
{
}
What is happening here is when i call mehod2 and pass value to it from list,
the method throws NoEntityFound excexption and ejb transaction rolls back.
In the catch block of method2 , i'm catching NoEntityFoundException and getting the programm flow to normal flow.
Throwing of NoEntiyFound exception is an expected behaviour.
But my requirement is that i need to continue the iteration over the other values in the list.
But when the programm comes back to method1 and the moment it does some
procesing i get exception like:
javax.transaction.RollbackException: Already marked for rollback, tx=TransactionImpl:XidImpl[FormatId=257,
GenericJDBCException..cannot open connection..session close....
1)What is the technical reson behind exception in method1?
2)What should i do to solve it so that my code processes the rest of the elements in the list?
Thanking in advance for any help.
Thanks
Vedgunjan
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4033496#4033496
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4033496
More information about the jboss-user
mailing list