Results 1 to 3 of 3

Thread: EJB requires new

  1. #1
    Join Date
    Mar 2007
    Location
    Poland
    Posts
    341

    Default EJB requires new

    Hi

    I have a problem with last project that integrates EJB, Spring and Hibernate.
    First, i would like to present architecture:

    WEB TIER -> EJBRemote ServiceA(BMT) -> Transaction Interceptor (Propagation Required, READ ONLY) -> POJO ServiceA (logic including some hibernate DAO)-> EJBLOCAL ServiceB(CMT) ->
    POJO ServiceB -> EJBLOCAL ServiceB(CMT) - REQUIRES NEW-> POJO ServiceB (login including some hibernate DAO).

    I realize that it looks quite weird - but it is all because of IBM folks who encourage to avoid transaction suspending in Websphere.

    Everything seems to work fine but the main problem is that SINGLE hibernate session is used by DAO executed in POJO ServiceA and POJO ServiceB.

    I see websphere trace files and all transactions are created as well.

    In logs i see:
    Code:
    javax.ejb.TransactionRolledbackLocalException:  ; nested exception is: org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.
    Does anyone know how it is possible that sharing pre-bound hibernate session occurs between transactions ??

  2. #2

    Default

    You don't say which version of Spring/WebSphere you are using.

    From Spring 2.1 there is support for a new WebSphereUOWTransactionManager that does allow suspend/resume semantics. This is available on WAS versions 6.0.2.19 or 6.1.0.9 or later:

    <bean id="transactionManager" class="org.springframework.transaction.jta.WebSphe reUowTransactionManager"/>

    Sara
    Sara Mitchell
    WebSphere Development
    MP 127 IBM Hursley Park Winchester SO21 2JN

  3. #3
    Join Date
    Mar 2007
    Location
    Poland
    Posts
    341

    Default

    Hi
    Thanks for an answer.
    We are using Websphere bundled with RAD 7.0 so i do not exactly the version number, but as far as i know it is one of these that don't allow spring to suspend transactions smoothly .
    I also use Hibernate 3.2.2 and spring 2.0.2

    On production environment we will be using websphere 6.1 where spring transaction are fully supported but still i wanna to find a solution cause we are not sure if we won't try to port the application to websphere 6.0.

    Since my last post i have made more digging and noticed that after starting spring transaction, retrieving hibernate session (SessionUtils class) in DAOs returns the same Session object even if new container transactions are created.
    It all means that one session object is shared across JTA transactions.
    where the first transactions is created by spring and others by CMT.
    But the most important is that I must make more tests if the session object releases database connection properly, cause if not, it will be total mess.

    If anyone see any idea please share it

Posting Permissions

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