Hi,
If you look at the transaction attributes,the problem is there.You have:
....
...
<props>
<prop
key="save*">PROPAGATION_REQUIRED,-UserExistsException</prop>
<prop key="remove*">PROPAGATION_REQUIRED</prop>
<prop key="topOff*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED, readOnly</prop>
</props>
....
....
So any method starting with "save" and "remove" are allowed to update
whereas all other methods have readonly property.So a very simple solution
to your problem is to remove the readOnly property in
<prop key="*">PROPAGATION_REQUIRED, readOnly</prop>
But obviously that would open up all methods to update and maybe there is a
security concern.Hope this helps.
-Chaitanya
Zakir wrote:
>
> Hello Experts.
> I am using appfuse, spring, and hibernate to create my project. I have a
> userManager, and a userDao for access to my "user" table. I am trying to
> run a quartz(1.5.2) cron job to iterate through my user table and edit an
> integer field (add some amount) for every user record. The method that I
> am calling from quartz is located within the userManager.
>
> the quartz configuration is below:
> *******************************
> <bean id="topOffJobDetail"
> class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
> <property name="targetObject" ref ="userManager"/>
> <property
> name="targetMethod"><value>topOffInvites</value></property>
> </bean>
> <bean id="topOffCronTrigger"
> class="org.springframework.scheduling.quartz.CronTriggerBean">
> <property name="jobDetail" ref="topOffJobDetail"/>
> <property name="cronExpression">
> <value>* 30 * * * ?</value>
> </property>
> </bean>
> <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
> <property name="triggers">
> <list>
> <ref local="topOffCronTrigger"/>
> </list>
> </property>
> </bean>
> **************************************************
>
> I have even configured this method in my transaction attributes as
> follows:
> <bean id="userManager" parent="txProxyTemplate">
> <property name="target">
> <bean
> class="com.ilr.razorpoints.service.impl.UserManagerImpl">
> <property name="userDao" ref="userDao"/>
> </bean>
> </property>
> <!-- Override default transaction attributes b/c of
> UserExistsException -->
> <property name="transactionAttributes">
> <props>
> <prop
> key="save*">PROPAGATION_REQUIRED,-UserExistsException</prop>
> <prop key="remove*">PROPAGATION_REQUIRED</prop>
> <prop key="topOff*">PROPAGATION_REQUIRED</prop>
> <prop key="*">PROPAGATION_REQUIRED, readOnly</prop>
> </props>
> </property>
> <!-- This property is overriden in applicationContext-security.xml
> to add
> method-level role security -->
> <property name="preInterceptors">
> <list>
> <ref bean="userSecurityInterceptor"/>
> </list>
> </property>
> </bean>
>
>
> Everytime the cronjob runs I get this error (everytime it tries to persist
> a a user after editing it.)
>
> **************************************
> org.springframework.dao.InvalidDataAccessApiUsageException: Write
> operations are not allowed in read-only mode (FlushMode.NEVER) - turn your
> Session into FlushMode.AUTO or remove 'readOnly' marker from transaction
> definition
> at
> org.springframework.orm.hibernate3.HibernateTemplate.checkWriteOperationAllowed(HibernateTemplate.java:1098)
> at
> org.springframework.orm.hibernate3.HibernateTemplate$18.doInHibernate(HibernateTemplate.java:692)
> at
> org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366)
> at
> org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:690)
> at
> com.ilr.razorpoints.dao.hibernate.UserDaoHibernate.saveUser(UserDaoHibernate.java:60)
> at
> com.ilr.razorpoints.service.impl.UserManagerImpl.topOffInvites(UserManagerImpl.java:99)
> at sun.reflect.GeneratedMethodAccessor90.invoke(Unknown Source)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:324)
> at
> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
> at
> org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
> at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
> at
> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
> at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
> at
> org.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:80)
> at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
> at
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
> at $Proxy1.topOffInvites(Unknown Source)
> at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:324)
> at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:248)
> at
> org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:165)
> at
> org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:90)
> at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
> at
> org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
> [razorpoints] DEBUG [DefaultQuartzScheduler_Worker-3]
> UserManagerImpl.testQuartz(83) | Quartz is working!!!
> [razorpoints] DEBUG [DefaultQuartzScheduler_Worker-7]
> UserManagerImpl.topOffInvites(87) | entering top off!
> [razorpoints] DEBUG [DefaultQuartzScheduler_Worker-7]
> UserManagerImpl.topOffInvites(97) | user mraible now has 6 invites left
> [razorpoints] DEBUG [DefaultQuartzScheduler_Worker-7]
> UserDaoHibernate.saveUser(57) | user's id: 2
> [razorpoints] DEBUG [DefaultQuartzScheduler_Worker-7]
> UserManagerImpl.topOffInvites(101) | error in saving user mraible
> org.springframework.dao.InvalidDataAccessApiUsageException: Write
> operations are not allowed in read-only mode (FlushMode.NEVER) - turn your
> Session into FlushMode.AUTO or remove 'readOnly' marker from transaction
> definition
> at
> org.springframework.orm.hibernate3.HibernateTemplate.checkWriteOperationAllowed(HibernateTemplate.java:1098)
> at
> org.springframework.orm.hibernate3.HibernateTemplate$18.doInHibernate(HibernateTemplate.java:692)
> at
> org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366)
> at
> org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:690)
> at
> com.ilr.razorpoints.dao.hibernate.UserDaoHibernate.saveUser(UserDaoHibernate.java:60)
> at
> com.ilr.razorpoints.service.impl.UserManagerImpl.topOffInvites(UserManagerImpl.java:99)
> at sun.reflect.GeneratedMethodAccessor90.invoke(Unknown Source)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:324)
> at
> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
> at
> org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
> at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
> at
> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
> at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
> at
> org.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:80)
> at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
> at
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
> at $Proxy1.topOffInvites(Unknown Source)
> at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:324)
> at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:248)
> at
> org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:165)
> at
> org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:90)
> at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
> at
> org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
> [razorpoints] DEBUG [DefaultQuartzScheduler_Worker-7]
> UserManagerImpl.topOffInvites(97) | user tomcat now has 6 invites left
> [razorpoints] DEBUG [DefaultQuartzScheduler_Worker-7]
> UserDaoHibernate.saveUser(57) | user's id: 1
> [razorpoints] DEBUG [DefaultQuartzScheduler_Worker-7]
> UserManagerImpl.topOffInvites(101) | error in saving user tomcat
> *****************************************
>
> I believe there is some kind of transaction issue. Any help is greatly
> appreciated.
>
--
View this message in context:
http://www.nabble.com/Appfuse-Spring-Hibernate-Quartz-InvalidDataAccessApiUsageException-tf2808582s2369.html#a7876994
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]