Announcement Announcement Module
Collapse
No announcement yet.
spring + hibernate (+ clob) transaction sychronization Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring + hibernate (+ clob) transaction sychronization

    I am using spring 1.1.2 , hibernate 2.1. and oracle 9i. I am using clobs.
    When trying to access records in the db I get the following error:

    Active Spring transaction synchronization or jtaTransactionManager on LocalSessionFactoryBean plus active JTA transaction required

    I looked through the forum and saw that I need to make Spring aware of my hibernate transactions.
    I configured it exactly how the forums indicated and yet I am still getting the error. What am I doing wrong? The following is my configuration.

    Code:
     
    
    
    <bean id="mySessionFactory"
    	      class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    		<property name="mappingLocations">
    			<list>
    				<value>/WEB-INF/QueryGroup.hbm.xml</value>
    				<value>/WEB-INF/Query.hbm.xml</value>
    				<value>/WEB-INF/ReportSource.hbm.xml</value>
    				<value>/WEB-INF/FTPQueryAction.hbm.xml</value>
    				<value>/WEB-INF/EmailQueryAction.hbm.xml</value>
    				<value>/WEB-INF/FTPHost.hbm.xml</value>
    				<value>/WEB-INF/EmailAddress.hbm.xml</value>
    				<value>/WEB-INF/GroupEmailInfo.hbm.xml</value>
    			</list>
    		</property>
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.dialect">net.sf.hibernate.dialect.Oracle9Dialect</prop>
    			</props>
    		</property>
    		<property name="dataSource">
    			<ref bean="dataSource"/>
    		</property>
    		<property name="lobHandler">
    				<ref local="oracleLobHandler"/>
    		</property>
      </bean>
      
      
      <!-- Database LOB Handling -->     
      <bean id="nativeJdbcExtractor"  class="org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor" lazy-init="true"/>    
      
      <bean id="oracleLobHandler"     class="org.springframework.jdbc.support.lob.OracleLobHandler">        
      		<property name="nativeJdbcExtractor">
      			<ref local="nativeJdbcExtractor"/>
      		</property>    
      </bean> 
    <!-- Hibernate Transaction Manager --> 
    <bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager"> 
    		  	<property name="sessionFactory">
    											<ref bean="mySessionFactory"/>
    					</property>
    		  </bean>
    		  
    <bean id="myTransactionManager" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    					<property name="transactionManager"><ref local="transactionManager"/></property>
    					<property name="target"><ref bean="/Retriever"/></property>
    					<property name="proxyTargetClass"><value>true</value></property> 
    					<property name="transactionAttributes">
    							<props>
    									<prop key="Save*">PROPAGATION_REQUIRED</prop>
    			            <prop key="save*">PROPAGATION_REQUIRED</prop>
    			            <prop key="get*">PROPAGATION_REQUIRED</prop>
    									<prop key="list*">PROPAGATION_REQUIRED</prop>			            
    							</props>
    					</property>
    	</bean>   
      
      
      <bean name="/Retriever" class="net.idt.ReportEngine.Editor.GroupEditor">
    						<property name="queryGroupDao"><ref bean="QueryGroupDao"/></property>
    	</bean>
    <bean id="QueryGroupDao" class="net.idt.ReportEngine.dao.QueryGroupDao">
    					<property name="sessionFactory">
    							<ref bean="mySessionFactory"/>
    					</property>
    	</bean>

  • #2
    Do you not need to explictly wrap "/Retriever"?

    My understanding (which is probably wrong ) is that you define your transactionManager, then define your bean, and then define a transactionAware proxy whose name is the bean you are wrapping, i.e.:

    <bean id="/RetrieverTarget" class="net.idt etc
    <bean name="/Retriever" class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="proxyInterfaces">
    <value>org.springframework.web.servlet.mvc.Control ler</value>
    </property>
    <property name="interceptorNames">
    <list>
    <value>transactionInterceptor</value>
    <value>/RetrieverTarget</value>
    </list>
    </property>
    </bean>

    Comment


    • #3
      expert one-on one says that TransactionProxyFactoryBean is an alternative simplified way of proxy coniguration. Using this you don't have to set up AOP proxyfactorybean.

      So what am I doing wrong?

      Comment


      • #4
        No idea then.

        Try throwing an exception in the middle of your business object so you can see exactly what is being adviced?

        Comment


        • #5
          same problem

          I'm having the exact same problems but trying to configure BLOBs... I trying several things and got to the same error as you. Will try some more and ler you know if I find something.

          Comment


          • #6
            when I configured it this way it works
            Code:
            		  <bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager"> 
            		  	<property name="sessionFactory">
            											<ref bean="mySessionFactory"/>
            					</property>
            		  </bean>
            		  
            		  <bean id="myTransactionManager" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
            					<property name="transactionManager"><ref local="transactionManager"/></property>
            					<property name="target"><ref bean="/Retriever"/></property>
            					<property name="proxyTargetClass"><value>true</value></property> 
            					<property name="transactionAttributes">
            							<props>
            
            
            			            <prop key="getGroups">PROPAGATION_REQUIRED</prop>
            
            									<prop key="*">PROPAGATION_REQUIRED</prop>
            						
            							</props>
            					</property>
            	</bean>   
            
            	<bean name="/Retriever" parent="myTransactionManager">
            	        <property name="target">
            	            <bean class="net.idt.ReportEngine.Editor.GroupEditor">
            	                <property name="queryGroupDao">
            	                    <ref bean="QueryGroupDao"/>
            	                </property>
            	                	            </bean>
            	        </property>
            	    </bean>

            However I now have a different problem.
            Posted: Wed Jun 08, 2005 9:36 am Post subject: ContextLoaderPlugIn problem

            --------------------------------------------------------------------------------

            I am using the ContextLoaderPlugIn.

            What do I do in the case where I have multiple struts actions that maps to the same class?
            They need to be different mappings because they are coming from different forms and therefore have different actionforms.
            I saw I can overide the bean name to map to with determineActionBeanName. How do I implement this?

            Comment

            Working...
            X