Announcement Announcement Module
Collapse
No announcement yet.
Quartz 1.5.2 + Spring + JDBC Jobstore Problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Quartz 1.5.2 + Spring + JDBC Jobstore Problem

    Hi, i have a little problem with quartz (v 1.5.2) and JDBCJobStore, problem is simple:

    I'm creating quartz Job POJO Class with simple task what printing on console "Hello" string, it looks like this:

    Code:
    public class SimpleQuartzTest extends QuartzJobBean {
    
    	@Override
    	protected void executeInternal(final JobExecutionContext context) throws JobExecutionException {
    		System.out.println("Hello");
    
    	}
    
    }
    next, I'm adding into spring context xml bean, what is creating quartz tables in my database, if don't exist.
    Code:
    <bean id="quartzDbInitializer" class="org.springframework.jdbc.datasource.init.DataSourceInitializer">
    	<property name="dataSource" ref="dataSource" />
    	<property name="enabled" value="true" />
    	<property name="databasePopulator">
    		<bean class="org.springframework.jdbc.datasource.init.ResourceDatabasePopulator">
                         ....
                    </bean>
            </property>
    </bean>
    and bean for creating scheduler, what use database tables created from code abow:

    Code:
    	<bean id="nextScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"
    		depends-on="quartzDbInitializer">
    
    		<property name="triggers">
    			<list>
    				<ref bean="cronTrigger" />
    			</list>
    		</property>
    		<property name="dataSource">
    			<ref bean="dataSource" />
    		</property>
    		<property name="transactionManager">
    			<ref bean="transactionManager" />
    		</property>
    		<property name="quartzProperties">
    			<props>
    				<prop key="org.quartz.jobStore.tablePrefix">
    				QRTZ_
    				</prop>
    				<prop key="org.quartz.jobStore.selectWithLockSQL">
    				SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?
    				</prop>
    			</props>
    		</property>
    	</bean>
    when I have database and scheduler ready, i'm creating jobDetail bean and trigger (running every 1 second) for SimpleQuartzTest Job represented by SimpleQuartzTest.class:

    Code:
    	<bean name="simpleQuartzTest" class="org.springframework.scheduling.quartz.JobDetailBean">
    		<property name="jobClass" value="pl.com.stream.next.asen.server.scheduling.SimpleQuartzTest" />
    	</bean>
    
    	<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    		<property name="jobDetail" ref="simpleQuartzTest" />
    		<property name="cronExpression" value="* * * * * ?" />
    	</bean>
    ok i have everything i want, I can run my application now.
    When i run my application, everything works fine, and 'Hello' is printing on screen. App works fine. so i close it.

    But, i think, that i don't need SimpleQuartzTest Job any more, so I want delete it. I remove SimpleQuartzTest.java file from workspace, JobDetailBean and CronTriggerBean from context xml file, I remove trigger from 'nextScheduler' bean to.

    When i run my application again, quartz want's to restore simpleQuartzTest from database, of course there is no more class name SimpleQuartzTest in project, so quartz gets ClassNotFoundException. As a result quartz don't start.

    In attachment is full exception I get (txt compressed by zip).

    What can I do with this ? maybe there is some property in quartz or spring what can i set and eliminate this problem.

    Thanks for all answers.
Working...
X