Hi there!
I'm doing something basic wrong and I'm not quite sure what it is. My Quartz code is running fine, and my Hibernate services run fine and are transactional and all that, but I can't get my Quartz beans to be wrapped in a Hibernate transaction. I've tried quite a few different things, but nothing's quite working.
Here's the XML in beans.xml, my basic stuff.
Here's the stuff I added this morning for Quartz and is not working like I expected.Code:<tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="*" propagation="REQUIRED"/> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="serviceOperations" expression="execution(* com.tamedtornado.services.*.*(..))"/> <aop:pointcut id="adminServiceOperations" expression="execution(* com.tamedtornado.services.admin.*.*(..))"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperations"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="adminServiceOperations"/> </aop:config> <!-- Needed a seperate one, for some reason admin wasn't being included in the above pointcut --> <bean id="myDataSource" class="org.apache.tomcat.dbcp.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://localhost:3306/gangster"/> <property name="username" value="*"/> <property name="password" value="*"/> </bean> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="mySessionFactory"/> </bean> <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="myDataSource"/> <property name="mappingDirectoryLocations"> <list> <value>WEB-INF/mapping</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> </props> </property> </bean>
I've been tinkering with this, so it's not how it was when I got closest to success, which meant I got my session factory injected, but still had no transactional context when I used getCurrentSession().Code:<aop:config> <aop:pointcut id="jobOperations" expression="execution(* com.tamedtornado.server.*.*(..))"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="jobOperations"/> </aop:config> <bean name="testJob" class="org.springframework.scheduling.quartz.JobDetailBean"> <property name="jobClass" value="com.tamedtornado.server.TestQuartzBean"/> <property name="jobDataAsMap"> <map> <entry key="blah" value="DUDE"/> <!-- This is always null, I managed to pass it in through the factory bean, but still no transactional context when I use getCurrentSession() --> <entry key="sessionFactory" value-ref="mySessionFactory"/> </map> </property> </bean> <bean id="simpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean"> <property name="jobDetail" ref="testJob"/> <property name="startDelay" value="1000"/> <property name="repeatInterval" value="10000"/> </bean> <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref bean="simpleTrigger"/> </list> </property> </bean>
I'm sure I'm just doing something stupid, can anyone help me out here?


Reply With Quote
