CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    May 2001
    Posts
    1

    EJB Transactions

    Hi All,
    I didn't find any actegory for EJB. That is why posting in this actegory.
    I am having some clarifications about EJB transactions.
    I am having a Session bean and two entity beans. I am using weblogic as the server. In my Session bean method I am interacting(creating) two entity beans. This two things I want to put it in a Single Transaction. For that In the deployement descriptor of Entity beans, I put the Transaction attribute 'supports' (<trans-attribute>Supports</trans-attribute&gt. In the Session bean I have put RequiresNew(<trans-attribute>RequiresNew</trans-attribute&gt as the attribute.
    But unfortunately when I call the session bean method it is not rolling back if one bean interaction fails. Is anything else has to be specified in the bean inorder to accomplish this. Please help me. Any suggestions will be appreciated.

    Sebas


  2. #2
    Join Date
    May 1999
    Location
    Pune, MH, India.
    Posts
    453

    Re: EJB Transactions

    If I am not mistaken, EJB1.1 specs say that the trasaction won't be rolled back automatically.

    They suggest to use context.setRollbackOnly() if you want to rollback a transaction in that case.

    Plz tell me if I am wrong!

    - UnicMan
    http://members.tripod.com/unicman

  3. #3
    Join Date
    Jul 2001
    Posts
    2

    Re: EJB Transactions

    Hi,i am facing similar problem in transactions.if you have found a workaround could you post it please.Only difference is that my app server is silverstream
    Thanks


  4. #4
    Join Date
    Jul 2001
    Posts
    10

    Re: EJB Transactions

    throw an exception from the entity bean...
    then in the session bean method, rethrow the exception to the container....

    it works with me.




  5. #5
    Join Date
    Jul 2001
    Posts
    2

    Re: EJB Transactions

    but i have read that the container will rollback only if system exception occurs.But if an application exception occurs then it does not rollback the transaction.The user has to call setRollbackOnly() method explicitly to rollback.
    Could you tell me what type of exception you were getting?


  6. #6
    Join Date
    Jul 2001
    Posts
    10

    Re: EJB Transactions

    in your entity bean use try-catch to catch your application exception and re-throw it...

    i normally rethrow it as java.rmi.RemoteException


  7. #7
    Join Date
    May 1999
    Location
    Pune, MH, India.
    Posts
    453

    Re: EJB Transactions

    There is one more thing I found out in case of Orion App Server.

    If you are trying on Orion, you should know that Orion server doesn't give error even if a method signature in descriptor is wrong or not specified.

    I think Orion server assumes that if method signature is not given, its default trans-attribute is taken as 'NotSupported'.

    I have a case where I had a descriptor with wrong method signature and whenever it used to fail, it used to say that it has rolled back transaction, but actually transaction wasn't rolledback.

    After that I learnt that because my method signature was wrong in descriptor, it was assuming 'NotSupported' attribute, and so whatever DB updates I do, were getting stored.

    I am not sure which app server are you trying, but ensure that signature in your descriptor matches exactly with the actual method.

    I hope it helps you...

    - UnicMan
    http://members.tripod.com/unicman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured