EJB programming & troubleshooting: can't serialize access for this transaction

  1. When two instances of two different beans try to update on one single row the following error occurs.
    In this case one transaction took place which commits the transaction while the second bean transaction gets rollback
    with following error
    Kindly let me know how to handle this at application level as well as in Database level.

    [java.sql.SQLException: ORA-08177: can't serialize access for this transaction
            at weblogic.ejb.internal.EntityEJBContext.beforeCompletion(EntityEJBContext.java:226)
            at weblogic.jts.internal.CoordinatorImpl.notifyBefore(CoordinatorImpl.java:627)
            at weblogic.jts.internal.CoordinatorImpl.prepare(CoordinatorImpl.java:421)
            at weblogic.jts.internal.CoordinatorImpl.commit(CoordinatorImpl.java:372)
            at weblogic.jts.internal.TxContext.commit(TxContext.java:255)
  2. hi,

    what is the object that u are passing to your bean or the parameter that u are passing ,

    the exception u gave here says that the container is unable to serialize the method call due to the isolation u provided
    take care that the data is serializable,
  3. This is the classic Oracle situation.

    To keep performance going Oracle does not check the serialization of a transaction in TX_SERIALIZABLE mode until it comes to commit the transaction. If it can't serialize it, you get the error you posted.

    Sybase, in contrast, will ensure the serialization of the transactions at all stages and this situation will not occur. Think the same is true of MS SQL-Server.

    Basically, you need to catch the exception and retry as far as I know, but I am not an Oracle expert so perhaps others have another solution which works better.

    This assumes you really need serializable transactions for these beans. If you don't then step it down and you should be OK.

    Hope that helps