Announcement Announcement Module
Collapse
No announcement yet.
JTA Hibernate exception - javax.transaction.RollbackException: null Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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!

    Frank

    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 com.ibm.ejs.jts.jta.UserTransactionImpl.commit(Use rTransactionImpl.java:197) at org.springframework.transaction.jta.JtaTransaction Manager.doCommit(JtaTransactionManager.java:781) at org.springframework.transaction.support.AbstractPl atformTransactionManager.processCommit(AbstractPla tformTransactionManager.java:496) at org.springframework.transaction.support.AbstractPl atformTransactionManager.commit(AbstractPlatformTr ansactionManager.java:469) at org.springframework.transaction.interceptor.Transa ctionAspectSupport.doCommitTransactionAfterReturni ng(TransactionAspectSupport.java:266) at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:106) at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :170) at org.springframework.aop.framework.Cglib2AopProxy$D ynamicAdvisedInterceptor.intercept(Cglib2AopProxy. java:643) at com.x.BusinessBroker$$EnhancerByCGLIB$$6c2a1d10.ge tDeelnemer() at com.x.ui.action.LoadWelkomAction.execute(LoadWelko mAction.java:86) at org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:484) at org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:274) at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1482) at org.apache.struts.action.ActionServlet.doGet(Actio nServlet.java:507) at javax.servlet.http.HttpServlet.service(HttpServlet .java:740) at javax.servlet.http.HttpServlet.service(HttpServlet .java:853) at com.ibm.servlet.engine.webapp.StrictServletInstanc e.doService(ServletManager.java:827) at com.ibm.servlet.engine.webapp.StrictLifecycleServl et._service(StrictLifecycleServlet.java:167) at com.ibm.servlet.engine.webapp.IdleServletState.ser vice(StrictLifecycleServlet.java:297) at com.ibm.servlet.engine.webapp.StrictLifecycleServl et.service(StrictLifecycleServlet.java:110) at com.ibm.servlet.engine.webapp.ServletInstance.serv ice(ServletManager.java:472) at com.ibm.servlet.engine.webapp.ValidServletReferenc eState.dispatch(ServletManager.java:1012) at com.ibm.servlet.engine.webapp.ServletInstanceRefer ence.dispatch(ServletManager.java:913) at com.ibm.servlet.engine.webapp.WebAppRequestDispatc her.handleWebAppDispatch(WebAppRequestDispatcher.j ava:721) at com.ibm.servlet.engine.webapp.WebAppRequestDispatc her.dispatch(WebAppRequestDispatcher.java:374) at com.ibm.servlet.engine.webapp.WebAppRequestDispatc her.forward(WebAppRequestDispatcher.java:118) at com.ibm.servlet.engine.srt.WebAppInvoker.doForward (WebAppInvoker.java:134) at com.ibm.servlet.engine.srt.WebAppInvoker.handleInv ocationHook(WebAppInvoker.java:239) at com.ibm.servlet.engine.invocation.CachedInvocation .handleInvocation(CachedInvocation.java:67) at com.ibm.servlet.engine.srp.ServletRequestProcessor .dispatchByURI(ServletRequestProcessor.java:151) at com.ibm.servlet.engine.oselistener.OSEListenerDisp atcher.service(OSEListener.java:317) at com.ibm.servlet.engine.http11.HttpConnection.handl eRequest(HttpConnection.java:60) at com.ibm.ws.http.HttpConnection.readAndHandleReques t(HttpConnection.java:391) at com.ibm.ws.http.HttpConnection.run(HttpConnection. java:284) at com.ibm.ws.util.CachedThread.run(ThreadPool.java:1 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"/>
    -->
    </bean>


    Spring config details, defining hibernate sessionFactory

    <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
    <property name="dataSource" ref="EpensioenDataSource"/>
    <property name="mappingResources">
    <list>
    <value>com/x/om/Regeling.hbm.xml</value>
    <value>com/x/om/Bron.hbm.xml</value>
    <value>com/x/om/Gebruiker.hbm.xml</value>
    </list>
    </property>
    <property name="hibernateProperties">
    <props>
    <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>
    </property>
    </bean>


    <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" />
    </property>

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

    <!-- 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="com.x.data.impl.DataAccessHandler" abstract="false" singleton="true" lazy-init="default" autowire="default" dependency-check="default">
    <property name="odlHandler" ref="${handler.odlHandlerReference}"/>
    <property name="epensioenHandler" ref="${handler.epensioenHandlerReference}"/>
    </bean>
    </property>
    </bean>


    Spring config, datasource definitions:

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

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

    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">
    <list>
    <value>classpath:application.properties</value>
    <value>classpath:database.properties</value>
    </list>
    </property>
    </bean>
    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.

    Comment


    • #3
      Thanks,

      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!

      Frank

      Comment


      • #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.

        Comment


        • #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):
          transaction.flush_before_completion=true
          transaction.auto_close_session=true
          connection.release_mode=auto
          transaction.factory_class=\
          org.hibernate.transaction.JTATransactionFactory
          transaction.manager_lookup_class=\
          org.hibernate.transaction.WebSphereTransactionMana gerLookup

          hope that helps,
          good luck,
          gerald

          Comment


          • #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.

            Comment

            Working...
            X