• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TxnRolledbackException instead of RemoteException

 
Binoj Viswanathan
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
____________________________________________________________
TransactionRolledbackException instead of RemoteException?
___________________________________________________________

Hi,
Mi client program is having following code snippet:

Object home = (DepartmentHome) ctx.lookup("DepartmentBean");
dHome = (DepartmentHome) PortableRemoteObject.narrow(home, DepartmentHome.class);

//Create a department with code=1000 and name=HR.

dept = (Department)dHome.create("1000","HR");
.............
............

dept.remove();
dHome.remove("1000");
*****************************
and DD i have

<container-transaction>
<method>
<ejb-name>DepartmentBean</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>

*************
@ line "dHome.remove("1000");" i'm getting following exception:
********
javax.transaction.TransactionRolledbackException: EJB Exception: : javax.ejb.NoSuchEntityException:
[EJB:010142]Instance of EJB 'DepartmentBean' with primary key '1000' does not exist.
*********
My client hasn't started txn.(if the client has started txn i shd get TransactionRolledbackException). As per EJB2.0 spec(p376 and p375) i shd get RemoteException(Not the RemoveExcpetion).Even with trans-attribute as "RequiresNew" im getting javax.transaction.TransactionRolledbackException


cn anione explain me Y this hapens?

thanx
binoj
 
Keerthi P
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are correct. It is surprising why you get TransactionRolledbackException in this case. btw what app server are you using?
[ February 22, 2005: Message edited by: Keerthi P ]
 
Binoj Viswanathan
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
im using weblogic8.1...

I dont see ani reazon to throw TransactionRolledbackException bak to the client as the tranx is started by the Container itself...The container can rollbak the tranx....


in place of folowin code snippet
*****************************

........
dept.remove();
dHome.remove("1000");
*****************************

i tried ths...
(1)
*****************************

........
dHome.remove("1000");// or dept.remove();
dept =dHome.findByName("HR");
*****************************

i got follwoing exc..n

*****************************
javax.ejb.ObjectNotFoundException: Bean not found in 'findByName'.
*****************************

(2)
*****************************

........
dHome.remove("1000");// or dept.remove();
dept.getCode() ;
*****************************

i got follwoing exc..n

*****************************
java.rmi.NoSuchObjectException: EJB Exception: : javax.ejb.NoSuchEntityException: [EJB:010140]Bean with primary key: '1000' not found.
*****************************


i think both r perfectli correct behaviours(as per ejb spec) of the container.

binoj
 
Sivakumar Nachimuthu
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I got the transactionrollBack Exception when using localHome.remove() method in the seesion bean.

Help me if u have any solution.

Thanks
Siva
 
Binoj Viswanathan
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I got the transactionrollBack Exception when using localHome.remove() method in the seesion bean.

Help me if u have any solution.


pls give us in detail...like,BMT or CMT, hu(container or client) initiated txn etc


binoj
 
Sivakumar Nachimuthu
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is CMP. Client Initiated tranaction thru session Bean.
 
Binoj Viswanathan
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
when u call localHome.remove() method in the seesion bean remote obj, the container will call ejbRemove()[if its SFSB] on the bean instance.If an exception happens during the removal of the bean instance it will throw RemoteException to the client. if the bean instance is running in client txn, in order to give the client more info, container will throw TxnRolledbackException. This is only applicable to container callbacks corresponding to the methods in home intf.

bin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic