Results 1 to 9 of 9

Thread: Spring 2.5.5 + Hibernate JPA + Atomikos = Strange Exceptions

  1. #1
    Join Date
    Nov 2008
    Location
    Ruhrpott, Germany
    Posts
    6

    Angry Spring 2.5.5 + Hibernate JPA + Atomikos = Strange Exceptions

    Hi Folks,

    trying to set up Atomikos Tx Manager i'm confrontated with strange exceptions (I've to use Atomikos because we've to use JBoss Cache for clustering issues).

    First of all, the used stuff:
    • Spring 2.5.5
    • Hibernate Core 3.3.1.GA
    • Hibernate Entitity Manager 3.4.0.GA
    • Hibernate Annotations 3.4.0.GA
    • Hibernate jbosscache2 3.3.1.GA
    • Atomikos Transactions Essentials 3.5.1
    • MySQL JDBC Connector 5.0.8 (for local MySQL) or jTDS 1.2.2 (MS SQl Server 2005)
    • running in Tomcat 5.5.26


    During little load, no problems are observed, but then my system starts to generate load (there are a bunch of threads started which process data and insert them into the DB in the background) those Exceptions are observed. They are the same on MySQL or MS SQL, only the stacktrace changes in the root cause classes are different (exceptions comming from jTDS instead of mysql jdbc driver):

    Code:
    java.sql.SQLException: Can't call commit when autocommit=true
    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:914)
    	at com.mysql.jdbc.Connection.commit(Connection.java:2275)
    	at com.atomikos.jdbc.nonxa.AtomikosThreadLocalConnection.transactionTerminated(AtomikosThreadLocalConnection.java:347)
    	at com.atomikos.jdbc.nonxa.AtomikosNonXAParticipant.commit(AtomikosNonXAParticipant.java:112)
    	at com.atomikos.icatch.imp.CommitMessage.send(CommitMessage.java:94)
    	at com.atomikos.icatch.imp.PropagationMessage.submit(PropagationMessage.java:86)
    	at com.atomikos.icatch.imp.Propagator$PropagatorThread.run(Propagator.java:62)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
    	at java.lang.Thread.run(Thread.java:619)
    This is strange, because autocommit is disabled explicitly and the exception dosn't occour on all commits.

    Most of the time, I got these:

    Code:
    09-02-19 10:03:25,750 [Atomikos:14] Error in non-XA commit
    com.atomikos.jdbc.AtomikosSQLException: Error in commit on vendor connection
    	at com.atomikos.jdbc.AtomikosSQLException.throwAtomikosSQLException(AtomikosSQLException.java:19)
    	at com.atomikos.jdbc.nonxa.AtomikosThreadLocalConnection.transactionTerminated(AtomikosThreadLocalConnection.java:358)
    	at com.atomikos.jdbc.nonxa.AtomikosNonXAParticipant.commit(AtomikosNonXAParticipant.java:112)
    	at com.atomikos.icatch.imp.CommitMessage.send(CommitMessage.java:94)
    	at com.atomikos.icatch.imp.PropagationMessage.submit(PropagationMessage.java:86)
    	at com.atomikos.icatch.imp.Propagator$PropagatorThread.run(Propagator.java:62)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
    	at java.lang.Thread.run(Thread.java:619)
    Caused by: com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Connection.close() has already been called. Invalid operation in this state.
    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:888)
    	at com.mysql.jdbc.Connection.getMutex(Connection.java:3714)
    	at com.mysql.jdbc.Connection.commit(Connection.java:2268)
    	at com.atomikos.jdbc.nonxa.AtomikosThreadLocalConnection.transactionTerminated(AtomikosThreadLocalConnection.java:347)
    	... 7 more
    followed by:
    Code:
    09-02-19 10:03:26,203 [Atomikos:14] Unexpected error in commit
    com.atomikos.icatch.HeurHazardException: Heuristic Exception
    	at com.atomikos.jdbc.nonxa.AtomikosNonXAParticipant.commit(AtomikosNonXAParticipant.java:115)
    	at com.atomikos.icatch.imp.CommitMessage.send(CommitMessage.java:94)
    	at com.atomikos.icatch.imp.PropagationMessage.submit(PropagationMessage.java:86)
    	at com.atomikos.icatch.imp.Propagator$PropagatorThread.run(Propagator.java:62)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
    	at java.lang.Thread.run(Thread.java:619)
    Here's my actual configuration. I've tried everything which I found, but without any significant change:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans  ...>
        <context:property-placeholder location="classpath:dbaccess.properties"/>
    	<tx:annotation-driven transaction-manager="txManager" />
    	<bean id="autoProxyCreator"
    		class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator">
    	</bean>	
    	<bean id="datasource" 
    		class="com.atomikos.jdbc.nonxa.AtomikosNonXADataSourceBean">
    		<property name="uniqueResourceName" value="NONXADBMS" />
    		<property name="user" value="${db.username}" />
    		<property name="password" value="${db.password}"/>
    		<property name="url" value="${db.url}"/>
    		<property name="driverClassName" value="${db.driverClassName}" />
    		<property name="poolSize" value="100" />
    		<property name="borrowConnectionTimeout" value="120" />
    		<property name="testQuery" value="SELECT 1" />
    		<property name="reapTimeout" value="0" />
    	</bean>	
    	
    	<bean id="entityManagerFactory"
    		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    		<property name="persistenceXmlLocation" value="classpath:los-persistence-jta.xml" />
    		<property name="dataSource" ref="datasource" />
    		<property name="jpaVendorAdapter">
    			<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
    				<property name="database" value="${db.database}" />
    				<property name="generateDdl" value="${db.generateDdl}" />
    				<property name="showSql" value="${db.showSql}" />
    				<property name="databasePlatform" value="${db.databasePlatform}" />
    			</bean>
    		</property>
    		<property name="jpaPropertyMap">
    			<map>
    				<entry key="hibernate.cache.use_second_level_cache" value="${hb.use_second_level_cache}"/>
    				<entry key="hibernate.cache.use_query_cache" value="${hb.use_query_cache}"/>
    				<entry key="hibernate.cache.region.factory_class" value="org.hibernate.cache.jbc2.MultiplexedJBossCacheRegionFactory"/>
    				<entry key="hibernate.cache.region.jbc2.configs" value="${hb.jbc2.configs}" />
    				<entry key="hibernate.cache.region.jbc2.cfg.entity" value="${hb.jbc2.entity}" />
    				<entry key="hibernate.transaction.manager_lookup_class" value="com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup"/>
    				<entry key="hibernate.hbm2ddl.auto" value="${db.ddl-create}"/>
    				<entry key="hibernate.connection.autocommit" value="false" />
    				<entry key="hibernate.connection.release_mode" value="after_transaction"/> <!-- Tried after_statement, too -->
    			</map>
    		</property>	
    	</bean>
    	
    	<bean id="userTransactionService" class="com.atomikos.icatch.config.UserTransactionServiceImp" init-method="init" destroy-method="shutdownForce">
    	    <constructor-arg>
    	        <props>
    	            <prop key="com.atomikos.icatch.service">com.atomikos.icatch.standalone.UserTransactionServiceFactory</prop>
    	            <prop key="com.atomikos.icatch.max_timeout">3600000</prop>
    	            <prop key="com.atomikos.icatch.default_jta_timeout">3600000</prop>
    	            <prop key="com.atomikos.icatch.max_actives ">200</prop>
    	        </props>
    	    </constructor-arg>
    	</bean>
    	
    	<bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager" init-method="init" destroy-method="close" depends-on="userTransactionService">
    		  <property name="startupTransactionService" value="true"/>
    		  <property name="forceShutdown" value="false" />
    	</bean>
    	
    	<bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp" depends-on="userTransactionService">
    	    <property name="transactionTimeout" value="3600000" />
    	</bean>
    	
    	<bean id="txManager" class="org.springframework.transaction.jta.JtaTransactionManager">
    		<property name="transactionManager"><ref bean="atomikosTransactionManager"  /></property>
    		<property name="userTransaction"><ref bean="atomikosUserTransaction"  /></property>
    		<property name="transactionSynchronizationName" value="SYNCHRONIZATION_ON_ACTUAL_TRANSACTION"/>
    	</bean>	
    	
    	<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
    </beans>
    Some additional words:
    • The Hibernate 2nd lvl Cache is disabled.
    • Then I switch my configuration too the good old Spring Tx Manager, everything works fine (using dbcp as the connection pool)


    It looks like that "something" is closing the connection which is used by the current transaction, maybe Hibernate (but set hibernate.connection.release_mode" value="after_transaction") or the connection pool (I'm using AtomikosNonXADataSourceBean).

    Any suggestion and/or help is welcome!!!

    Is there any other alternative to Atomikos? JOTM is a bit old and AFAIK not supported anymore.

    Bye
    HGU

  2. #2

    Default Atomikos forums

    Hi,

    The Atomikos forums would be a better place to post this IMHO?

    Please send a tm.out file produced in DEBUG mode to support at atomikos dot com

    Thanks

  3. #3

    Default Please upgrade to 3.5.2

    Hi,

    At least the autocommit problem should have been solved in release 3.5.2 - available via Atomikos.

    The other problem (connection closed) is under inspection by our development team so any logs would help.

    Thanks

    Guy

  4. #4
    Join Date
    Nov 2008
    Location
    Ruhrpott, Germany
    Posts
    6

    Default

    Quote Originally Posted by GuyPardon View Post
    Hi,

    At least the autocommit problem should have been solved in release 3.5.2 - available via Atomikos.

    The other problem (connection closed) is under inspection by our development team so any logs would help.

    Thanks

    Guy
    Dear Guy,

    thank you! I'll upgrade to 3.5.2 and then create the debug output and send it to the support mail adress.

    Edit: I'was unable to post in the Atomikos forum (getting error Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.), but have posted a trace with 3.5.2 to the support.
    Last edited by hgu; Feb 20th, 2009 at 12:07 PM. Reason: Update

  5. #5
    Join Date
    Nov 2008
    Location
    Ruhrpott, Germany
    Posts
    6

    Question No answer yet :-(

    Quote Originally Posted by GuyPardon View Post
    Hi,

    At least the autocommit problem should have been solved in release 3.5.2 - available via Atomikos.

    The other problem (connection closed) is under inspection by our development team so any logs would help.

    Thanks

    Guy
    Dear Guy,

    I've still no feedback to my mail from the atomikos support. I know, it's open source, and I've not bought any support, but....

    BTW, I can't post into the atomikos forum, getting these MS errors.

  6. #6

    Default 3.5.3

    Hi,

    We are investigating a number of related problems for the 3.5.3 release - thanks...

    Guy

  7. #7
    Join Date
    Dec 2008
    Posts
    5

    Default

    I had a problem somewhat like this one, though I'm using commons DBCP not Atomikos.
    I found a hint here:
    http://jira.springframework.org/browse/SPR-960

    And found that this:
    <property name="jpaPropertyMap">
    <map>
    <entry key="hibernate.connection.release_mode" value="on_close"/>
    </map>
    </property>
    ..fixed my issue.

    Yes the Jira is quite old...I'm on Spring 2.5 here and Hibernate 3.3.1 core like yourself.
    Theoretically Spring since 1.2 means on_close is/was defaulted.
    Last edited by beniggulden; Apr 8th, 2010 at 09:34 PM. Reason: prose perfectionism

  8. #8
    Join Date
    Nov 2010
    Posts
    1

    Default

    Hi, The Atomikos forums would be a better place to post this IMHO? Please send a tm.out file produced in DEBUG mode to support at atomikos dot com Thanks Hi, At least the autocommit problem should have been solved in release 3.5.2 - available via Atomikos....

  9. #9
    Join Date
    Feb 2011
    Posts
    1

    Default

    each time a description of the change, there is always plenty to talk about around the world. they are not exempt. a statement usually are: "i have to change almost immediately versions, so do not expect me to date continue to attack ..

    Testking
    ccie
    ccna
    ccnp dumps

Tags for this Thread

Posting Permissions

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