This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of Zero to AI - A non-technical, hype-free guide to prospering in the AI era and have Nicolò Valigi and Gianluca Mauro on-line!
See this thread for details.
Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Some questions about transactions and reentrancy

 
Greenhorn
Posts: 13
  • 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
     
    Ranch Hand
    Posts: 80
    • 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.
     
    Greenhorn
    Posts: 17
    • 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
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks to all for your responses!!!
     
    Ranch Hand
    Posts: 59
    • 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
    • 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 ]
     
    Ranch Hand
    Posts: 47
    • 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
    • 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
    • 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
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    thanks. I am not aware of that.

    bhilla
     
    Lautaro Brasseur
    Greenhorn
    Posts: 13
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I passed the exam with 100%!!!
     
    Don't destroy the earth! That's where I keep all my stuff! Including this tiny ad:
    Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    reply
      Bookmark Topic Watch Topic
    • New Topic