Announcement Announcement Module
No announcement yet.
JTA Hibernate exception - javax.transaction.RollbackException: null Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • JTA Hibernate exception - javax.transaction.RollbackException: null

    Hi all,

    I've got a situation with two Oracle9 databases which I need to access. One I access using Spring StoredProcedure support and the other one I access using Hibernate2 configured through Spring.

    When I remove the transaction attributes everything works fine. But as soon as I mark certain methods with PROPAGATION_REQUIRED I get an UnexpectedRollbackException.

    I searched the spring api's, reference manuals, googled and searched the forums and concluded that it must have something todo with the usertransaction manager and the strict JTA implementations of Websphere after transaction completion. But I can't get it to work.

    I have two questions:
    - one what is wrong in the configuration underneath?
    - do I realy need JTA in THIS situation, since one database is read-only (the one which I access using Stored Procedures)? At stage 3 of the Proof of Concept this database will also be accessed for write operations, so then I will need JTA.

    Thanks a lot!


    I changed the package names underneath on request of the customer (privacy thing...)

    Websphere details:

    WebSphere AEs 4.0.6 ptf60319.01 running with process name localhost/Default Server and process id 2272
    Host Operating System is Windows XP, version 5.1
    Java version = J2RE 1.3.1 IBM Windows 32 build cn131w-20030329 ORB130 (JIT enabled: jitc), Java Compiler = jitc, Java VM name = Classic VM
    Current trace specification = *=all=disabled
    ************* End Display Current Environment *************
    [12-1-06 16:11:25:385 CET] 5c4f6736 Server U Version : 4.0.6
    [12-1-06 16:11:25:385 CET] 5c4f6736 Server U Edition: Advanced Single Server Edition for Multiplatforms
    [12-1-06 16:11:25:400 CET] 5c4f6736 Server U Build date: Tue May 13 00:00:00 CEST 2003
    [12-1-06 16:11:25:400 CET] 5c4f6736 Server U Build number: ptf60319.01

    Exception details:
    org.springframework.transaction.UnexpectedRollback Exception: JTA transaction unexpectedly rolled back (maybe due to a timeout); nested exception is javax.transaction.RollbackException: null javax.transaction.RollbackException at at org.springframework.transaction.jta.JtaTransaction Manager.doCommit( at atformTransactionManager.processCommit(AbstractPla at atformTransactionManager.commit(AbstractPlatformTr at org.springframework.transaction.interceptor.Transa ctionAspectSupport.doCommitTransactionAfterReturni ng( at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:106) at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed( :170) at org.springframework.aop.framework.Cglib2AopProxy$D ynamicAdvisedInterceptor.intercept(Cglib2AopProxy. java:643) at com.x.BusinessBroker$$EnhancerByCGLIB$$ tDeelnemer() at com.x.ui.action.LoadWelkomAction.execute(LoadWelko at org.apache.struts.action.RequestProcessor.processA ctionPerform( at org.apache.struts.action.RequestProcessor.process( at org.apache.struts.action.ActionServlet.process(Act at org.apache.struts.action.ActionServlet.doGet(Actio at javax.servlet.http.HttpServlet.service(HttpServlet .java:740) at javax.servlet.http.HttpServlet.service(HttpServlet .java:853) at e.doService( at et._service( at vice( at et.service( at ice( at eState.dispatch( at ence.dispatch( at her.handleWebAppDispatch(WebAppRequestDispatcher.j ava:721) at her.dispatch( at her.forward( at ( at ocationHook( at .handleInvocation( at .dispatchByURI( at atcher.service( at eRequest( at t( at java:284) at 44)

    Spring config details, getting the websphere4 transaction manager:

    <bean id="websphereTransactionManager" class="org.springframework.transaction.jta.WebSphe reTransactionManagerFactoryBean"/>

    <!-- We gebruiken de jta transactie manager vanuit de appliation server, deze wordt opgehaald uit Websphere op een
    middels een specifieke class. Werkt voor Websphere 4, 5.0 en 5.1 -->
    <bean id="jtaTxManager" class="org.springframework.transaction.jta.JtaTran sactionManager">
    <property name="transactionManager" ref="websphereTransactionManager"/>
    <property name="userTransactionName" value="jta/usertransaction"/>

    <property name="autodetectTransactionManager" value="false"/>

    Spring config details, defining hibernate sessionFactory

    <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
    <property name="dataSource" ref="EpensioenDataSource"/>
    <property name="mappingResources">
    <property name="hibernateProperties">
    <prop key="hibernate.dialect">${database.epensioen.hiber nate.dialect}</prop>
    <prop key="hibernate.cache.provider_class">${database.ep ensioen.hibernate.cache.provider}</prop>
    <!-- Voor ontwikkel willen we graag de gegenereerde SQL zien: -->
    <prop key="show_sql">${database.epensioen.showsql}</prop>
    <prop key="use_outer_join">true</prop>

    <bean id="txProxyTemplate" abstract="true" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean" singleton="true" lazy-init="default" autowire="default" dependency-check="default">
    <property name="transactionManager">
    <ref bean="jtaTxManager" />

    <!-- Geef hier aan welke methodes transaction aware moeten worden -->
    <property name="transactionAttributes">
    <prop key="get*">PROPAGATION_REQUIRED</prop>

    <!-- Maak de Service transaction aware, de te gebruiken implementatie classes worden gespecificeerd in de omgeving specifieke property files in de profile directory -->
    <bean id="dataAccessHandler" parent="txProxyTemplate" abstract="false" singleton="true" lazy-init="default" autowire="default" dependency-check="default">
    <property name="target">
    <bean class="" abstract="false" singleton="true" lazy-init="default" autowire="default" dependency-check="default">
    <property name="odlHandler" ref="${handler.odlHandlerReference}"/>
    <property name="epensioenHandler" ref="${handler.epensioenHandlerReference}"/>

    Spring config, datasource definitions:

    <bean id="ODLDataSource" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiName" value="${database.odl.datasource}"/>

    <bean id="EpensioenDataSource" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiName" value="${database.epensioen.datasource}"/>

    And ofcourse the PropertyPlaceHolder:
    <!--Gebruik property file om omgeving specifieke zaken te regelen, hierdoor kan deze config file voor elke OTAP omgeving hetzelfde blijven -->
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer" abstract="false" singleton="true" lazy-init="default" autowire="default" dependency-check="default">
    <property name="locations">
    Last edited by Franky; Jan 13th, 2006, 02:06 AM. Reason: Important for introducing Spring at major client in Project

  • #2
    I don't think you really need JTA if one of the databases is read-only.


    • #3

      So for now I can work arround this, but in fase 3 of the Project I will need to update both databases. So then I do need JTA transactions to work!

      I'am working on a Project at a Big Insurance company in the Netherlands. I introduced Spring in some small projects using Spring MVC and the Spring core.

      In this Project the customer is testing if Spring can really proof it self and deserves a place on the list of allowed opensource frameworks. I'am convinced but the customer isn't yet, and the pressure is rising...

      So please help me out!



      • #4
        Even if you are working with 2 databases if one is read-only then you don't really need transactions or in any case - you don't need JTA since the two transactions (if you would have them) don't need to be related.
        I assume the problem lies somewhere in the JTA TM from WebSphere - you can avoid this by using local TMs - a simple JDBC/Datasource one for your jdbc access to the stored procedure and a HibernateTM for the Hibernate access. Mark the read-only transactions accordingly to squeeze some performance.


        • #5
          check JDBC driver, datasources and Hibernate config

          hi franky (haven't read that much dutch in a while ;-)

          supposing you want to get this exact scenario (2 DBs, Spring-managed TX, JTA) working:

          - do you use the correct JDBC driver and does it support XA? i don't know about websphere but on weblogic we had all sorts of strange problems until we switched from the oracle JDBC driver to BEA's own driver for Oracle (although both were XA-capable). (a FAQ, as it turned out)

          - are your datasources XA-enabled?

          - regarding your Hibernate configuration, i would also include the following (you need to check whether these options are available in Hibernate2 at all - i can't really remember how things were before Hibernate3):
          org.hibernate.transaction.WebSphereTransactionMana gerLookup

          hope that helps,
          good luck,


          • #6
            Problem solved, as always simple solution!

            Thanks a lot Ravan and Gerald,

            the oracle driver class was not correct in the datasource definition. I changed it to oracle.jdbc.xa.client.OracleXADataSource and everything works fine now!
            Last edited by Franky; Jan 13th, 2006, 06:26 AM.