jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hamid Reza Sahlolbey" <sahlol...@gmail.com>
Subject RE: Jackrabbit+Hibernate_Jencks xa transactions in Spring
Date Fri, 29 Feb 2008 05:55:50 GMT
Hi, 
Can you please send us your Spring config for XA transactions?

Cheers,
Hamid



-----Original Message-----
From: jorge08 [mailto:jorcardozo@gmail.com] 
Sent: 2008/02/28 07:31 ب.ظ
To: users@jackrabbit.apache.org
Subject: Jackrabbit+Hibernate_Jencks xa transactions in Spring


I am trying to setup XA transactions in Spring to wrap up Hibernate and
Jackrabbit transactions. My hibernate transactions are working, but it seems
that Jackrabbit is not joining the transaction. The following test will not
rollback when the exception is thrown.

public String addFile(FileNodeType fileNode, InputStream in) throws
myException {
…
	getJcrDAO().save();

	throw new RepositoryException("Exception thrown");
}


And here is part of my Spring configuration file:


<!-- Transaction manager configuration for Jencks -->
    <bean id="connectionTracker"
class="org.apache.geronimo.connector.outbound.connectiontracking.ConnectionT
rackingCoordinator"/>
  
    <bean id="transactionManagerImpl"
class="org.jencks.factory.TransactionManagerFactoryBean">
        <property name="defaultTransactionTimeoutSeconds" value="1800"/>
        <property name="transactionLog">
            <bean
class="org.apache.geronimo.transaction.log.UnrecoverableLog"/>
        </property>
    </bean>
  
    <bean id="transactionContextManager"
class="org.jencks.factory.TransactionContextManagerFactoryBean">
        <property name="transactionManager" ref="transactionManagerImpl"/>
    </bean>

    <bean id="userTransaction"
class="org.jencks.factory.UserTransactionFactoryBean">
        <property name="transactionContextManager"
ref="transactionContextManager"/>
        <property name="connectionTrackingCoordinator"
ref="connectionTracker"/>
    </bean>

    <bean id="transactionContextInitializer"
class="org.jencks.interceptor.TransactionContextInitializer">
        <property name="associator" ref="connectionTracker"/>
    </bean>  
  
     <!-- JCA configuration -->
    <bean id="transactionSupport"
class="org.jencks.factory.XATransactionFactoryBean">
        <property name="useTransactionCaching" value="true"/>
        <property name="useThreadCaching" value="false"/>
    </bean>

    <bean id="poolingSupport"
class="org.jencks.factory.SinglePoolFactoryBean">
        <property name="maxSize" value="50"/>
        <property name="minSize" value="5"/>
        <property name="blockingTimeoutMilliseconds" value="1000"/>
        <property name="idleTimeoutMinutes" value="60"/>
        <property name="matchOne" value="true"/>
        <property name="matchAll" value="true"/>
        <property name="selectOneAssumeMatch" value="true"/>
    </bean>

    <bean id="connectionManager"
class="org.jencks.factory.ConnectionManagerFactoryBean">
        <property name="transactionSupport" ref="transactionSupport"/>
        <property name="poolingSupport" ref="poolingSupport"/>
        <property name="transactionContextManager"
ref="transactionContextManager"/>
        <property name="connectionTracker" ref="connectionTracker"/>
    </bean>

    <!-- common properties -->
    <bean id="xaTransactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
        <property name="userTransaction">
            <ref local="userTransaction"/>
        </property>
        <property name="transactionManager">
            <ref local="transactionManagerImpl"/>
        </property>
    </bean>

  
 	<!-- **************************************************
		***************** Hibernate Config ***************
		************************************************** -->
	<!-- This bean defines the database information -->
	<bean class="com.mchange.v2.c3p0.ComboPooledDataSource"
		id="dataSource" destroy-method="close">
		<property name="driverClass">
			<value>@driverClassName@</value>
		</property>
		<property name="jdbcUrl">
			<value>@driverUrl@</value>
		</property>
		<property name="properties">
			<props>
				<prop key="c3p0.acquire_increment">5</prop>
				<prop key="c3p0.idle_test_period">100</prop>
				<prop key="c3p0.max_statements">0</prop>
				<prop key="c3p0.min_size">3</prop>
				<prop key="maxPoolSize">5</prop>
				<prop key="user">@username@</prop>
				<prop key="password">@password@</prop>
			</props>
		</property>
	</bean> 
	
	<bean id="sessionFactory"
	
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="mappingResources">
			<list>
	
<value>/org/ABC/myProj/model/UserInfo.hbm.xml</value>
				...
			</list>
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">
					org.hibernate.dialect.Oracle9Dialect
				</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop
key="hibernate.jdbc.use_get_generated_keys">
					true
				</prop>
				<prop
key="hibernate.max_fetch_depth">3</prop>
				<prop
key="hibernate.jdbc.fetch_size">5</prop>
				<prop
key="hibernate.jdbc.batch_size">20</prop>
				<prop
key="hibernate.use_outer_join">true</prop>
				<prop key="cache.provider_class">
					org.hibernate.cache.NoCacheProvider
				</prop>
				<prop
key="cache.use_query_cache">false</prop>
				<prop
key="cache.use_minimal_puts">false</prop>
			</props>
		</property>
	</bean>

 
	<!--***********************************************
		******* Helper class that simplifies Hibernate 
		data access code, and converts checked HibernateExceptions 
		into unchecked DataAccessExceptions,  ************
		***********************************************-->
	<bean id="hibernateTemplate"
	
class="org.springframework.orm.hibernate3.HibernateTemplate">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>


    <!-- The next 3 beans are to support source-level Spring transaction
configuration: -->
    <bean
class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCr
eator"/>

    <bean
class="org.springframework.transaction.interceptor.TransactionAttributeSourc
eAdvisor">
        <property name="transactionInterceptor"
ref="transactionInterceptor"/>
        <property name="order" value="0"/>
    </bean>

    <bean id="transactionInterceptor"    
class="org.springframework.transaction.interceptor.TransactionInterceptor">
        <property name="transactionManager" ref="xaTransactionManager"/>
        <property name="transactionAttributeSource">
            <bean
class="org.springframework.transaction.annotation.AnnotationTransactionAttri
buteSource"/>
        </property>
    </bean>
    
    
      
  
  

	<bean id="repository"
	
class="org.springmodules.jcr.jackrabbit.RepositoryFactoryBean">
		<!-- normal factory beans params -->
		<property name="configuration"
			value="/WEB-INF/my-repository.xml" />
	</bean>


	<!-- JCR SessionFactory -->
	<bean id="jcrSessionFactory"
	
class="org.ABC.myProj.webapp.util.myJackrabbitSessionFactory">
		<property name="repository" ref="repository" />
		<property name="credentials">
			<bean class="javax.jcr.SimpleCredentials">
				<constructor-arg index="0" value="bogus" />
				<!-- create the credentials using a bean
factory -->
				<constructor-arg index="1">
					<bean factory-bean="password"
						factory-method="toCharArray"
/>
				</constructor-arg>
			</bean>
		</property>
		<property name="workspaceName" value="@wsp.name@" />
		<property name="skipExistingNamespaces" value="true" />
		<property name="contentType" value="text/x-jcr-cnd" />
		<property name="nodeDefinitions">

			<list>
				<value>/WEB-INF/myNodeTypes.cnd</value>
			</list>
		</property>
	</bean>


	<bean id="jcrTemplate" class="org.springmodules.jcr.JcrTemplate">
		<property name="sessionFactory" ref="jcrSessionFactory" />
		<property name="allowCreate" value="true" />
	</bean>
	

	<bean id="txProxyTemplate" abstract="true"
	
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBe
an">
		<property name="proxyTargetClass">
			<value>true</value>
		</property>
		<property name="transactionManager">
			<ref local="xaTransactionManager" />
		</property>
		<property name="transactionAttributes">
			<props>
				<prop key="*">PROPAGATION_REQUIRED</prop>
			</props>
		</property>
	</bean>


		
		
	<!--***********************************************
		***************   Services  *******************
		***********************************************-->

 
	<bean id="nodeService" parent="txProxyTemplate">
		<property name="target"> 	
			<bean
class="org.ABC.myProj.service.impl.NodeServiceImpl">
				<property name="jcrDAO" ref="jcrDao" />
				<property name="userDao" ref="userDao" />
			</bean>
		</property>
	</bean>

 	<bean id="userService" parent="txProxyTemplate">
		<property name="target"> 	
		<bean
			class="org.ABC.myProj.service.impl.UserServiceImpl">
			<property name="userDao" ref="userDao" />
			<property name="dao" ref="baseDAO" />	
		</bean>
		</property>
	</bean>
		
	...

	<!-- **************************************************
		*****************   DAO's  ***********************
		************************************************** -->

	<bean
	
class="org.springframework.orm.hibernate3.support.HibernateDaoSupport"
		id="hibernateSupport" abstract="true">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>

	<bean id="userDao"
		class="org.ABC.myProj.dao.impl.UserDaoImpl">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>

	<bean id="jcrDao" class="org.ABC.myProj.dao.impl.JcrBaseDAO">
		<property name="template" ref="jcrTemplate" />
	</bean>
	

	<bean id="baseDAO"
		class="org.ABC.myProj.dao.impl.BaseDAOHibernateImpl"
		parent="hibernateSupport" />	
		
	...


Versions:
Tomcat 6.0
Hibernate 3.2
Jackrabbit 1.3.3
Jencks 1.3
Spring 2.0.1


Please help!





-- 
View this message in context:
http://www.nabble.com/Jackrabbit%2BHibernate_Jencks-xa-transactions-in-Sprin
g-tp15739597p15739597.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Mime
View raw message