Page 3 of 3 FirstFirst 123
Results 21 to 24 of 24

Thread: HibernateTransactionManager doesn't work

  1. #21
    Join Date
    Jun 2007
    Posts
    25

    Default

    Yes, I was.

    It was temporary solution to see if transactions are working in my application.
    Now I have to use JTA transaction manager and it's not working

  2. #22
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Could you posted the updated parts of the configuration, along with the DEBUG logging?
    Last edited by karldmoore; Aug 29th, 2007 at 11:14 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  3. #23
    Join Date
    Jun 2007
    Posts
    25

    Default

    My configuration for JTA transaction look like this:

    Code:
    	<bean id="userFacade" class="org.bivela.business.facade.UserFacade">
    		<property name="sessionFactory"><ref bean="userSessionFactory" /></property>
    	</bean>
    
            <bean id="jtaTransactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">		
    	</bean>		
    	<bean id="jtaTransactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
    		<property name="transactionManager"><ref local="jtaTransactionManager" /></property>	
    		<property name="transactionAttributeSource">
    			<value>				org.bivela.business.facade.UserFacadeInterface.updateShareholders=PROPAGATION_REQUIRED
    			</value>
    		</property>
    	</bean>
    
    	<bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
    		<property name="sessionFactory"><ref bean="userSessionFactory" /></property>
    	</bean>
    	 
    	<bean id="userProxyService" class="org.springframework.aop.framework.ProxyFactoryBean">
    		<property name="proxyInterfaces">
    			<value>org.bivela.business.facade.UserFacadeInterface</value>
    		</property>
    		<property name="target" ref="userFacade" />
    		<property name="interceptorNames">
    			<list>							
    				<!-- <value>hibernateInterceptor</value> -->
    				<value>jtaTransactionInterceptor</value>				
    			</list>
    		</property>
    	</bean>
    
    	<bean id="userDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    			<property name="driverClassName">
    				<value>${db.driver}</value>
    			</property>
    			<property name="url">
    				<value>${db.url}</value>
    			</property>
    			<property name="username">
    				<value>${user.name}</value>
    			</property>
    			<property name="password">
    				<value>${user.password}</value>
    			</property>
    			
    			 
    			<property name="maxActive">
    				<value>15</value>
    			</property>
    	 	</bean> 
    
    
    		<property name="jtaTransactionManager">
    			<bean id="jtaTransactionManager.transactionManager" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
    		</property>
    		
    		<property name="hibernateProperties">
    			<props>						
    				<prop key="hibernate.dialect">${hibernate.dialect}</prop>
    				<prop key="hibernate.show_sql">true</prop>
    				<prop key="hibernate.current_session_context_class">thread</prop>
    				<prop key="hibernate.max_fetch_depth">3</prop>
    				
    				<prop key="hibernate.connection.pool_size">3</prop>
    				<prop key="hibernate.connection.isolation">2</prop>
    				<prop key="hibernate.connection.release_mode">after_transaction</prop>
    				<prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
    				<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
    								
    				<prop key="hibernate.hbm2dll.auto">create</prop>
               						
    				<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop>	
    			</props>
    		</property>
    	</bean>
    and debug file:

    Code:
    2007-07-03 10:01:40,024 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] Using transaction object [org.springframework.transaction.jta.JtaTransactionObject@2f0e07]
    2007-07-03 10:01:40,024 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] Creating new transaction with name [org.bivela.business.facade.UserFacadeInterface.updateShareholders]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
    2007-07-03 10:01:40,024 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Initializing transaction synchronization
    2007-07-03 10:01:40,026 DEBUG [org.springframework.transaction.interceptor.TransactionInterceptor] Getting transaction for [org.bivela.business.facade.UserFacadeInterface.updateShareholders]
    2007-07-03 10:01:40,026 DEBUG [org.springframework.orm.hibernate3.SessionFactoryUtils] Opening Hibernate Session
    2007-07-03 10:01:40,033 DEBUG [org.hibernate.jdbc.JDBCContext] successfully registered Synchronization
    2007-07-03 10:01:40,033 DEBUG [org.hibernate.impl.SessionImpl] opened session at timestamp: 11834497000
    2007-07-03 10:01:40,033 DEBUG [org.springframework.orm.hibernate3.SessionFactoryUtils] Registering Spring transaction synchronization for new Hibernate Session
    2007-07-03 10:01:40,043 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Bound value [org.springframework.orm.hibernate3.SessionHolder@16a90c9] for key [org.hibernate.impl.SessionFactoryImpl@1479784] to thread [http-0.0.0.0-8443-3]
    2007-07-03 10:01:40,044 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Retrieved value [org.springframework.orm.hibernate3.SessionHolder@16a90c9] for key [org.hibernate.impl.SessionFactoryImpl@1479784] bound to thread [http-0.0.0.0-8443-3]
    2007-07-03 10:01:40,045 DEBUG [org.springframework.orm.hibernate3.HibernateTemplate] Found thread-bound Session for HibernateTemplate
    2007-07-03 10:01:40,045 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Retrieved value [org.springframework.orm.hibernate3.SessionHolder@16a90c9] for key [org.hibernate.impl.SessionFactoryImpl@1479784] bound to thread [http-0.0.0.0-8443-3]
    2007-07-03 10:01:40,046 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
    2007-07-03 10:01:40,046 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
    2007-07-03 10:01:40,046 DEBUG [org.hibernate.SQL] select companies0_.id as id5_, companies0_.name as name5_, 
    
    ....
    
    2007-07-03 10:01:40,052 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Retrieved value [org.springframework.orm.hibernate3.SessionHolder@16a90c9] for key [org.hibernate.impl.SessionFactoryImpl@1479784] bound to thread [http-0.0.0.0-8443-3]
    2007-07-03 10:01:40,052 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Retrieved value [org.springframework.orm.hibernate3.SessionHolder@16a90c9] for key [org.hibernate.impl.SessionFactoryImpl@1479784] bound to thread [http-0.0.0.0-8443-3]
    2007-07-03 10:01:40,053 DEBUG [org.springframework.orm.hibernate3.HibernateTemplate] Found thread-bound Session for HibernateTemplate
    2007-07-03 10:01:40,053 DEBUG [org.hibernate.hql.ast.QueryTranslatorImpl] parse() - HQL: select share from org.bivela.dto.bivela.Shareholders share JOIN FETCH share.company company WHERE company.id = ?
    
    ...
    
    2007-07-03 10:01:40,226 DEBUG [org.hibernate.engine.StatefulPersistenceContext] initializing non-lazy collections
    2007-07-03 10:01:40,226 DEBUG [org.springframework.orm.hibernate3.HibernateTemplate] Not closing pre-bound Hibernate Session after HibernateTemplate
    2007-07-03 10:01:40,226 DEBUG [org.springframework.transaction.interceptor.TransactionInterceptor] Completing transaction for [org.bivela.business.facade.UserFacadeInterface.updateShareholders] after exception: org.hibernate.HibernateException: Blad wymuszony
    2007-07-03 10:01:40,226 DEBUG [org.springframework.transaction.interceptor.RuleBasedTransactionAttribute] Applying rules to determine whether transaction should rollback on org.hibernate.HibernateException: Blad wymuszony
    2007-07-03 10:01:40,227 DEBUG [org.springframework.transaction.interceptor.RuleBasedTransactionAttribute] Winning rollback rule is: null
    2007-07-03 10:01:40,227 DEBUG [org.springframework.transaction.interceptor.RuleBasedTransactionAttribute] No relevant rollback rule found: applying superclass default
    2007-07-03 10:01:40,227 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] Triggering beforeCompletion synchronization
    2007-07-03 10:01:40,234 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Removed value [org.springframework.orm.hibernate3.SessionHolder@16a90c9] for key [org.hibernate.impl.SessionFactoryImpl@1479784] from thread [http-0.0.0.0-8443-3]
    2007-07-03 10:01:40,234 DEBUG [org.springframework.orm.hibernate3.SessionFactoryUtils] Closing Hibernate Session
    2007-07-03 10:01:40,234 DEBUG [org.hibernate.jdbc.ConnectionManager] releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
    2007-07-03 10:01:40,236 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] Initiating transaction rollback
    2007-07-03 10:01:40,236 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
    2007-07-03 10:01:40,236 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] Triggering afterCompletion synchronization
    2007-07-03 10:01:40,236 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Clearing transaction synchronization
    2007-07-03 10:01:40,236 DEBUG [org.springframework.web.servlet.DispatcherServlet] Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@13214d1
    2007-07-03 10:01:40,237 DEBUG [org.springframework.web.servlet.DispatcherServlet] Could not complete request
    org.hibernate.HibernateException: Blad wymuszony
    	at org.bivela.business.facade.UserFacade.updateShareholders(UserFacade.java:1377)
    I use JBoss and MySQL servers.
    Last edited by martique; Jul 3rd, 2007 at 03:15 AM.

  4. #24
    Join Date
    Jun 2007
    Posts
    25

    Default

    I've noticed that when I'm using jta transaction manager, hibernate session is closed before transaction rollback action.

    So, can somebody help me with this configuration, please?

Posting Permissions

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