File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Some questions about transactions and reentrancy

 
Lautaro Brasseur
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
     
    Kay Ra
    Ranch Hand
    Posts: 80
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 17
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    *******************************************
    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
    Posts: 13
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks to all for your responses!!!
     
    bhilla ratna
    Ranch Hand
    Posts: 59
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
     
    Lautaro Brasseur
    Greenhorn
    Posts: 13
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 47
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    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
    Posts: 13
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 13
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks for responses to points B and C too. I'll take the exam tomorrow...
     
    bhilla ratna
    Ranch Hand
    Posts: 59
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    thanks. I am not aware of that.

    bhilla
     
    Lautaro Brasseur
    Greenhorn
    Posts: 13
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I passed the exam with 100%!!!
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic