users@glassfish.java.net

Re: EjbTransaction Rollback and PersistenetContext

From: Witold Szczerba <pljosh.mail_at_gmail.com>
Date: Sun, 1 Apr 2007 15:56:23 +0200

First thing I can see here is that you call #method2 DIRECTLY.
In that case, there is nothing that could possibly interpret
#method2's annotation and do something about it. Annotations are just
annotations, nothing more.
Try invoking #method2 using EJB infrastructure and maybe that will help.

-josh

2007/3/31, glassfish_at_javadesktop.org <glassfish_at_javadesktop.org>:
> 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 void 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 because of which 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 an EJbTransactionRollBack exceptions , saying generice JDBC exception..cannot open connection..session close...etc
>
> 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
> [Message sent by forum member 'vedgunjan' (vedgunjan)]
>
> http://forums.java.net/jive/thread.jspa?messageID=210727
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>