Announcement Announcement Module
Collapse
No announcement yet.
Transaction doesn't start! Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transaction doesn't start!

    Hello, everyone!
    I'm using spring 1.2.1, hibernate 3 and Oracle9i.
    My problem is that Transaction doesn't start in my application.
    Here's my applicationContext.xml

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
     "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    
      <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName">
          <value>java&#58;comp/env/test</value>
        </property>
      </bean>
    
      <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="mappingResources">
          <list>
            <value>model/base/TimecardDaily.hbm.xml</value>
            <value>model/base/TimecardSpecial.hbm.xml</value>
            <value>model/base/TimecardUser.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.use_outer_join">true</prop>
          </props>
        </property>
        <property name="dataSource">
          <ref bean="dataSource"/>
        </property>
      </bean>
    
      <bean id="userDao" class="dao.UserDao">
        <property name="sessionFactory">
          <ref bean="sessionFactory"/>
        </property>
      </bean>
    
      <bean id="dailyDao" class="dao.DailyDao">
        <property name="sessionFactory">
          <ref bean="sessionFactory"/>
        </property>
      </bean>
    
      <bean id="timecardService" class="dao.TimecardServiceImpl">
        <property name="userDao">
          <ref bean="userDao"/>
        </property>
        <property name="dailyDao">
          <ref bean="dailyDao"/>
        </property>
      </bean>
    
      <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory">
          <ref bean="sessionFactory"/>
        </property>
      </bean>
    
      <bean id="facade" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
        <property name="transactionManager">
          <ref bean="transactionManager"/>
        </property>
        <property name="target">
          <ref bean="timecardService"/>
        </property>
        <property name="transactionAttributes">
          <props>
            <prop key="search*">PROPAGATION_REQUIRED,readOnly</prop>
            <prop key="update*">PROPAGATION_REQUIRED</prop>
          </props>
        </property>
      </bean>
    
    </beans>
    And when I try to update the Oracle table with this code,

    Code:
    package  dao;
    
    import  model.*;
    import  org.springframework.orm.hibernate3.*;
    import  org.springframework.orm.hibernate3.support.*;
    
    public  class  DailyDao  extends  HibernateDaoSupport
    &#123;
        public  void  updateDaily&#40;DailyData daily&#41;
        &#123;
            getHibernateTemplate&#40;&#41;.saveOrUpdate&#40;daily&#41;;
        &#125;
    &#125;
    I get an error

    Code:
    org.springframework.dao.InvalidDataAccessApiUsageException&#58; Write operations are not allowed in read-only mode &#40;FlushMode.NEVER&#41; - turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition
    	at org.springframework.orm.hibernate3.HibernateTemplate.checkWriteOperationAllowed&#40;HibernateTemplate.java&#58;910&#41;
    	at org.springframework.orm.hibernate3.HibernateTemplate$18.doInHibernate&#40;HibernateTemplate.java&#58;614&#41;
    	at org.springframework.orm.hibernate3.HibernateTemplate.execute&#40;HibernateTemplate.java&#58;312&#41;
    	at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate&#40;HibernateTemplate.java&#58;612&#41;
    	at dao.DailyDao.updateDaily&#40;Unknown Source&#41;
    	at dao.TimecardServiceImpl.updateDaily&#40;Unknown Source&#41;
    	at portal.beans.DailyManager.update&#40;Unknown Source&#41;
    	at sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Native Method&#41;
    	at sun.reflect.NativeMethodAccessorImpl.invoke&#40;Unknown Source&#41;
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;Unknown Source&#41;
    	at java.lang.reflect.Method.invoke&#40;Unknown Source&#41;
    	at org.apache.myfaces.el.MethodBindingImpl.invoke&#40;MethodBindingImpl.java&#58;138&#41;
    	at org.apache.myfaces.application.ActionListenerImpl.processAction&#40;ActionListenerImpl.java&#58;62&#41;
    	at javax.faces.component.UICommand.broadcast&#40;UICommand.java&#58;106&#41;
    	at javax.faces.component.UIViewRoot._broadcastForPhase&#40;UIViewRoot.java&#58;110&#41;
    	at javax.faces.component.UIViewRoot.processApplication&#40;UIViewRoot.java&#58;184&#41;
    	at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication&#40;LifecycleImpl.java&#58;259&#41;
    	at org.apache.myfaces.lifecycle.LifecycleImpl.execute&#40;LifecycleImpl.java&#58;90&#41;
    	at javax.faces.webapp.FacesServlet.service&#40;FacesServlet.java&#58;109&#41;
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter&#40;ApplicationFilterChain.java&#58;237&#41;
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter&#40;ApplicationFilterChain.java&#58;157&#41;
    	at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal&#40;OpenSessionInViewFilter.java&#58;172&#41;
    	at org.springframework.web.filter.OncePerRequestFilter.doFilter&#40;OncePerRequestFilter.java&#58;76&#41;
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter&#40;ApplicationFilterChain.java&#58;186&#41;
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter&#40;ApplicationFilterChain.java&#58;157&#41;
    	at filter.NoCacheFilter.doFilter&#40;Unknown Source&#41;
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter&#40;ApplicationFilterChain.java&#58;186&#41;
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter&#40;ApplicationFilterChain.java&#58;157&#41;
    	at filter.EncodingFilter.doFilter&#40;Unknown Source&#41;
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter&#40;ApplicationFilterChain.java&#58;186&#41;
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter&#40;ApplicationFilterChain.java&#58;157&#41;
    	at org.apache.catalina.core.StandardWrapperValve.invoke&#40;StandardWrapperValve.java&#58;214&#41;
    	at org.apache.catalina.core.StandardValveContext.invokeNext&#40;StandardValveContext.java&#58;104&#41;
    	at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;520&#41;
    	at org.apache.catalina.core.StandardContextValve.invokeInternal&#40;StandardContextValve.java&#58;198&#41;
    	at org.apache.catalina.core.StandardContextValve.invoke&#40;StandardContextValve.java&#58;152&#41;
    	at org.apache.catalina.core.StandardValveContext.invokeNext&#40;StandardValveContext.java&#58;104&#41;
    	at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;520&#41;
    	at org.apache.catalina.core.StandardHostValve.invoke&#40;StandardHostValve.java&#58;137&#41;
    	at org.apache.catalina.core.StandardValveContext.invokeNext&#40;StandardValveContext.java&#58;104&#41;
    	at org.apache.catalina.valves.ErrorReportValve.invoke&#40;ErrorReportValve.java&#58;117&#41;
    	at org.apache.catalina.core.StandardValveContext.invokeNext&#40;StandardValveContext.java&#58;102&#41;
    	at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;520&#41;
    	at org.apache.catalina.core.StandardEngineValve.invoke&#40;StandardEngineValve.java&#58;109&#41;
    	at org.apache.catalina.core.StandardValveContext.invokeNext&#40;StandardValveContext.java&#58;104&#41;
    	at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;520&#41;
    	at org.apache.catalina.core.ContainerBase.invoke&#40;ContainerBase.java&#58;929&#41;
    	at org.apache.coyote.tomcat5.CoyoteAdapter.service&#40;CoyoteAdapter.java&#58;160&#41;
    	at org.apache.coyote.http11.Http11Processor.process&#40;Http11Processor.java&#58;793&#41;
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection&#40;Http11Protocol.java&#58;702&#41;
    	at org.apache.tomcat.util.net.TcpWorkerThread.runIt&#40;PoolTcpEndpoint.java&#58;571&#41;
    	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run&#40;ThreadPool.java&#58;644&#41;
    	at java.lang.Thread.run&#40;Unknown Source&#41;
    I think it'll go away when the transaction start successfully.
    Do I need more description in the applicationContext.xml?
    I'll really welcome any help.

  • #2
    I can't see any invocation of a transactional proxy in your example--are you sure you're not invoking the target directly? I would suggest using an inner bean for the target, instead of a ref, which would make this problem impossible.

    Comment


    • #3
      Thank you!

      First, thank you very much for your quick reply!
      My problem has been solved with your advice.
      I'd better have read the chapter 7 of the documents more carefully.
      Anyway, thank you very much again!
      I'm looking forward to your lecture in Tokyo tomorrow!

      Comment

      Working...
      X