permaculture playing cards*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Some questions about transactions and reentrancy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Some questions about transactions and reentrancy" Watch "Some questions about transactions and reentrancy" New topic
Author

Some questions about transactions and reentrancy

Lautaro Brasseur
Greenhorn

Joined: Aug 06, 2005
Posts: 13
Hi, I will take the SCBCD exam and I have some questions:

  • What Entity bean reentrancy means? A reentrant Entity bean can be accessed concurrently by many clients?
  • In HFEJB, page 582, says that the <method-intf> tag can be used to differentiate methods with same name in component and home interfaces, regarding security access. Can this tag be applied for transaction attributes too? Or if the same method are used in both, component and home interfaces, the transaction attribute must be the same?
  • Page 552 of HFEJB says that TransactionRequiredException and TransactionRequiredLocalException are thrown when you call a method with 'Mandatory' attribute without having the caller a transaction active. Which exception is thrown if you call a method with attribute 'Never' from a client with an active transaction? Is there an equivalent exception?
  • If a bean method throws a system exception and the caller is in the same transaction, the caller will receive a TransactionRolledBackException/TransactionRolledBackLocalException, right? (HFEJB, page 552 too) What happens if the caller is not in the same transaction, for example, if the method has a 'RequiresNew' attribute? Which exception could the caller receive?



  • Thanks in advance

    Lautaro


    Lautaro Brasseur<br />SCJP 1.4 (95%) / SCBCD 1.3 (100%)
    Kay Ra
    Ranch Hand

    Joined: May 03, 2005
    Posts: 80
    Answer to the reentrancy part

    1. Only entity beans can be reentrant
    2. Reentrant means if the beans methods can call itself again, akin to a recursive method.Basically a loop back.
    Thomas Vezhambacheril
    Greenhorn

    Joined: Aug 02, 2005
    Posts: 17
    *******************************************
    If a bean method throws a system exception and the caller is in the same transaction, the caller will receive a TransactionRolledBackException/TransactionRolledBackLocalException, right? (HFEJB, page 552 too) What happens if the caller is not in the same transaction, for example, if the method has a 'RequiresNew' attribute? Which exception could the caller receive?
    *************************************************************

    I think it will not roll back the previous transaction(which is propagated from clent or prvious bean),but will throw RemoteException for remote clients and EJBException for local clients
    Lautaro Brasseur
    Greenhorn

    Joined: Aug 06, 2005
    Posts: 13
    Thanks to all for your responses!!!
    bhilla ratna
    Ranch Hand

    Joined: Jun 01, 2005
    Posts: 59
    For TransactionRolledback exception question:

    The client still receives TransactionRolledbackException but the container transaction will still continue, i.e. the transaction in which the exception has occured will be rolledback

    bhilla


    Ratna bhilla<br />SCJP 1.4, SCBCD 1.3, SCWCD 1.4
    Lautaro Brasseur
    Greenhorn

    Joined: Aug 06, 2005
    Posts: 13
    I just found table 15, in pages 375-376 of the spec, look for:

    Method condition:
    Bean method runs in the context of a transaction that the Container started immediately before dispatching the business method. This case may happen with Required and RequiresNew attributes.

    Method exception:
    all other exceptions

    Container�s action:
    Log the exception or error.
    Rollback the container-started transaction.
    Discard instance.
    Throw RemoteException to remote client; throw EJBException to local client.

    Client�s view:
    Receives RemoteException or EJBException.
    If the client executes in a transaction, the client�s transaction may or may not be marked for rollback.

    If the client has unspecified transaction context, it has similar results. TransactionRolledbackException is only thrown when bean transaction is the same of the caller.

    However, if the callers lets the exception to propagate... TransactionRolledbackException/TransactionRolledbackLocalException are system exception, I think that caller transaction would be rolled back too. Because of that (I believe), the specification says:

    "If the client executes in a transaction, the client�s transaction may or may not be marked for rollback."
    [ August 10, 2005: Message edited by: Lautaro Brasseur ]
    seemapanth Joshi
    Ranch Hand

    Joined: Nov 28, 2004
    Posts: 47

    B. In HFEJB, page 582, says that the <method-intf> tag can be used to differentiate methods with same name in component and home interfaces, regarding security access. Can this tag be applied for transaction attributes too? Or if the same method are used in both, component and home interfaces, the transaction attribute must be the same?

    Yes, this tag can be applied for transaction attributes too, as per the DD DTD.


    C. Page 552 of HFEJB says that TransactionRequiredException and TransactionRequiredLocalException are thrown when you call a method with 'Mandatory' attribute without having the caller a transaction active. Which exception is thrown if you call a method with attribute 'Never' from a client with an active transaction? Is there an equivalent exception?

    Yes, they are java.rmi.RemoteException and java.ejb.EJBException for remote and local clients respectively. Spec Page 359.
    [ August 11, 2005: Message edited by: seemapanth Joshi ]
    Lautaro Brasseur
    Greenhorn

    Joined: Aug 06, 2005
    Posts: 13
    In my last post, I talked about TransactionRolledbackException/TransactionRolledbackLocalException propagation. It should be EJBException/RemoteException, wich are thrown if methos doesn't run in caller transaction...
    Lautaro Brasseur
    Greenhorn

    Joined: Aug 06, 2005
    Posts: 13
    Thanks for responses to points B and C too. I'll take the exam tomorrow...
    bhilla ratna
    Ranch Hand

    Joined: Jun 01, 2005
    Posts: 59
    thanks. I am not aware of that.

    bhilla
    Lautaro Brasseur
    Greenhorn

    Joined: Aug 06, 2005
    Posts: 13
    I passed the exam with 100%!!!
     
     
    subject: Some questions about transactions and reentrancy
     
    Similar Threads
    Container-Transaction tag ???
    Exam Details
    IBM 287 ICE TEST
    EJB Notes I prepared during my preparation for SCBCD
    SCBCD Objectives