Announcement Announcement Module
Collapse
No announcement yet.
problem creating quartz task Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • problem creating quartz task

    Hi,
    I feel that the problem I'm having must have the simpliest solution... there just might be something I've overlooked, but I just can't figure it out. I'm trying to create some simple scheduling with quartz but I just seem to get this exception:

    [code]
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.scheduling.quartz.SchedulerFa ctoryBean' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Initialization of bean failed; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery.
    [code]

    the quarz configuration in dispatcher servlet is this:

    [code]
    <!-- Quartz configuration -->
    <bean id="exampleBusinessObject" class="org.my.own.package.MailSenderTest">
    <property name="mailCreator" ref="mailCreator" />
    </bean>

    <bean id="jobDetail" class="org.springframework.scheduling.quartz.Metho dInvokingJobDetailFactoryBean">
    <property name="targetObject" ref="exampleBusinessObject"/>
    <property name="targetMethod" value="doIt" />
    <property name="concurrent" value="false"/>
    </bean>

    <bean id="simpleTrigger" class="org.springframework.scheduling.quartz.Simpl eTriggerBean">
    <!-- see the example of method invoking job above -->
    <property name="jobDetail" ref="jobDetail"/>
    <!-- 10 seconds -->
    <property name="startDelay" value="10000"/>
    <!-- repeat every 50 seconds -->
    <property name="repeatInterval" value="50000"/>
    </bean>

    <bean class="org.springframework.scheduling.quartz.Sched ulerFactoryBean">
    <property name="triggers">
    <list>
    <ref bean="simpleTrigger"/>
    </list>
    </property>
    </bean>
    &#91;/code&#93;

    I'd be most pleased if someone could help me on this problem.

  • #2
    Ok, this wasn't as simple as I tought... I've had 2 persons to check it out, one of which is extremely familiar with spring, other with quartz. Yet no clue what-so-ever. My spring version is 1.2.1 and quartz 1.4.5.

    I'd be glad of any assitance.

    Comment


    • #3
      Here is the full stacktrace, if it helps.

      Code:
      org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'org.springframework.scheduling.quartz.SchedulerFactoryBean' defined in ServletContext resource &#91;/WEB-INF/dispatcher-servlet.xml&#93;&#58; Initialization of bean failed; nested exception is org.quartz.SchedulerConfigException&#58; Failure occured during job recovery.
      	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;361&#41;
      	org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;223&#41;
      	org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;147&#41;
      	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons&#40;DefaultListableBeanFactory.java&#58;271&#41;
      	org.springframework.context.support.AbstractApplicationContext.refresh&#40;AbstractApplicationContext.java&#58;312&#41;
      	org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh&#40;AbstractRefreshableWebApplicationContext.java&#58;134&#41;
      	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext&#40;FrameworkServlet.java&#58;305&#41;
      	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext&#40;FrameworkServlet.java&#58;250&#41;
      	org.springframework.web.servlet.FrameworkServlet.initServletBean&#40;FrameworkServlet.java&#58;219&#41;
      	org.springframework.web.servlet.HttpServletBean.init&#40;HttpServletBean.java&#58;111&#41;
      	javax.servlet.GenericServlet.init&#40;GenericServlet.java&#58;211&#41;
      	org.apache.catalina.authenticator.AuthenticatorBase.invoke&#40;AuthenticatorBase.java&#58;482&#41;
      	org.apache.catalina.valves.ErrorReportValve.invoke&#40;ErrorReportValve.java&#58;105&#41;
      	org.apache.catalina.connector.CoyoteAdapter.service&#40;CoyoteAdapter.java&#58;148&#41;
      	org.apache.coyote.http11.Http11Processor.process&#40;Http11Processor.java&#58;856&#41;
      	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection&#40;Http11Protocol.java&#58;744&#41;
      	org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket&#40;PoolTcpEndpoint.java&#58;527&#41;
      	org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt&#40;LeaderFollowerWorkerThread.java&#58;80&#41;
      	org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run&#40;ThreadPool.java&#58;684&#41;
      	java.lang.Thread.run&#40;Thread.java&#58;595&#41;

      Comment


      • #4
        I've managaed to make some progress. I've noticed that however i configure quartz at the end I will get following exception:
        Code:
        HTTP Status 500 -
        
        type Exception report
        
        message
        
        description The server encountered an internal error &#40;&#41; that prevented it from fulfilling this request.
        
        exception
        
        javax.servlet.ServletException&#58; Servlet.init&#40;&#41; for servlet dispatcher threw exception
        	org.apache.catalina.authenticator.AuthenticatorBase.invoke&#40;AuthenticatorBase.java&#58;482&#41;
        	org.apache.catalina.valves.ErrorReportValve.invoke&#40;ErrorReportValve.java&#58;105&#41;
        	org.apache.catalina.connector.CoyoteAdapter.service&#40;CoyoteAdapter.java&#58;148&#41;
        	org.apache.coyote.http11.Http11Processor.process&#40;Http11Processor.java&#58;856&#41;
        	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection&#40;Http11Protocol.java&#58;744&#41;
        	org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket&#40;PoolTcpEndpoint.java&#58;527&#41;
        	org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt&#40;LeaderFollowerWorkerThread.java&#58;80&#41;
        	org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run&#40;ThreadPool.java&#58;684&#41;
        	java.lang.Thread.run&#40;Thread.java&#58;595&#41;
        
        root cause
        
        org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'org.springframework.scheduling.quartz.SchedulerFactoryBean' defined in ServletContext resource &#91;/WEB-INF/dispatcher-servlet.xml&#93;&#58; Initialization of bean failed; nested exception is org.quartz.JobPersistenceException&#58; Couldn't store job&#58; org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean
        	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;361&#41;
        	org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;223&#41;
        	org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;147&#41;
        	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons&#40;DefaultListableBeanFactory.java&#58;271&#41;
        	org.springframework.context.support.AbstractApplicationContext.refresh&#40;AbstractApplicationContext.java&#58;312&#41;
        	org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh&#40;AbstractRefreshableWebApplicationContext.java&#58;134&#41;
        	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext&#40;FrameworkServlet.java&#58;305&#41;
        	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext&#40;FrameworkServlet.java&#58;250&#41;
        	org.springframework.web.servlet.FrameworkServlet.initServletBean&#40;FrameworkServlet.java&#58;219&#41;
        	org.springframework.web.servlet.HttpServletBean.init&#40;HttpServletBean.java&#58;111&#41;
        	javax.servlet.GenericServlet.init&#40;GenericServlet.java&#58;211&#41;
        	org.apache.catalina.authenticator.AuthenticatorBase.invoke&#40;AuthenticatorBase.java&#58;482&#41;
        	org.apache.catalina.valves.ErrorReportValve.invoke&#40;ErrorReportValve.java&#58;105&#41;
        	org.apache.catalina.connector.CoyoteAdapter.service&#40;CoyoteAdapter.java&#58;148&#41;
        	org.apache.coyote.http11.Http11Processor.process&#40;Http11Processor.java&#58;856&#41;
        	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection&#40;Http11Protocol.java&#58;744&#41;
        	org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket&#40;PoolTcpEndpoint.java&#58;527&#41;
        	org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt&#40;LeaderFollowerWorkerThread.java&#58;80&#41;
        	org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run&#40;ThreadPool.java&#58;684&#41;
        	java.lang.Thread.run&#40;Thread.java&#58;595&#41;
        
        note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.
        Apache Tomcat/5.5.9
        I have configured quartz in following way:
        Code:
          <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        
            <property name="quartzProperties">
              <props>
                <prop key="org.quartz.scheduler.instanceName">RiskienhallintaScheduler</prop>
                <prop key="org.quartz.scheduler.instanceId">instance_1</prop>
                <prop key="org.quartz.scheduler.rmi.export">false</prop>
                <prop key="org.quartz.scheduler.rmi.proxy">false</prop>
                
                <prop key="org.quartz.threadPool.class">org.quartz.simpl.SimpleThreadPool</prop>
                <prop key="org.quartz.threadPool.threadCount">3</prop>
                
        		<prop key="org.quartz.jobStore.class">org.quartz.simpl.RAMJobStore</prop>
        
              </props>
            </property>
            <property name="triggers">
              <list>
                <ref bean="cronTrigger"/>
              </list>
            </property>
          </bean>
        I'm found out that if I remove the declaration of triggers from the SchedulerFactoryBean the program will run fine (except it wont work

        Code:
          <bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
            <property name="targetObject" ref="mailSenderTest"/>
            <property name="targetMethod" value="doIt"/>
          </bean>
          
          <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
            <property name="jobDetail" ref="jobDetail"/>
        	<!-- run every 5th minute -->
            <property name="cronExpression" value="0 0/5 * * * ?"/>
          </bean>
        
          
          <bean id="mailSenderTest" class="my.own.package.notifier.MailSenderTest">
            <property name="mailCreator" ref="mailCreator" />
          </bean>
        That's how I configure the job. mailCreator is a working bean which I've already tested, it depends on one other bean. Hope this information helps you to help me.

        Comment


        • #5
          No JobFactory in org.quartz.spi

          Error creating bean with name 'org.springframework.scheduling.quartz.SchedulerFa ctoryBean#0' defined in class path


          the actual error is Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/quartz/spi/JobFactory

          if you look in the quartz.jar, there is no org/quartz/spi/JobFactory

          Comment


          • #6
            Try using quartz 1.6.0

            In quartz 1.6.0 you can find the JobFactory class in org.quartz.spi package. (But in previous releases such as quartz 1.4.5 this is not the case)

            Comment


            • #7
              even quartz-1.5.1.jar will also work ...

              Comment


              • #8
                solution???

                Me too gettin the same exception............. if anyone knows the solution please let me know.........tried using quartz 1.6.0 and quartz 1.5.1
                the stack trace is given below
                Code:
                org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SchedulerFactory' defined in class path resource [spring-config-global.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/quartz/spi/JobFactory
                	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
                	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
                	at java.security.AccessController.doPrivileged(Native Method)
                	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
                	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
                	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
                	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
                	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
                	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
                	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
                	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
                	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
                	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
                	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:105)
                	at com.nisco.common.ServiceLocator.getAppContext(ServiceLocator.java:58)
                	at com.nisco.common.ServiceLocator.findService(ServiceLocator.java:64)
                	at com.nisco.common.ServiceLocator.findSchedulerEventService(ServiceLocator.java:198)
                	at com.nisco.web.jsf.CustomerFaceServlet.init(CustomerFaceServlet.java:28)
                	at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:276)
                	at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
                	at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
                	at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:68)
                	at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
                	at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48)
                	at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:493)
                	at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1688)
                	at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1665)
                	at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1585)
                	at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2678)
                	at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:874)
                	at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:326)
                	at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:114)
                	at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
                	at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
                	at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
                	at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:25)
                	at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:640)
                	at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
                	at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:252)
                	at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:154)
                	at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80)
                	at weblogic.deploy.internal.targetserver.BasicDeployment.activate(BasicDeployment.java:176)
                	at weblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:347)
                	at weblogic.management.deploy.internal.DeploymentAdapter$1.activate(DeploymentAdapter.java:50)
                	at weblogic.management.deploy.internal.AppTransition$2.transitionApp(AppTransition.java:30)
                	at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:232)
                	at weblogic.management.deploy.internal.ConfiguredDeployments.activate(ConfiguredDeployments.java:168)
                	at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:122)
                	at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:173)
                	at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:89)
                	at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
                	at weblogic.work.ServerWorkManagerImpl$WorkAdapterImpl.run(ServerWorkManagerImpl.java:518)
                	at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
                	at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
                My config xml file

                <bean id="beginAutoStagerObject"
                class="com.razorsight.common.scheduler.SchedulerCo ntroller" />

                <bean id="beginAutoStagingJobDetail"
                class="org.springframework.scheduling.quartz.Metho dInvokingJobDetailFactoryBean">
                <property name="targetObject" ref="beginAutoStagerObject" />
                <property name="targetMethod" value="beginAutoStagingInvoices" />
                <property name="concurrent" value="false" />
                </bean>

                <!-- Trigger which will execute based on certain cron expression-->

                <bean id="cronTrigger"
                class="org.springframework.scheduling.quartz.CronT riggerBean">
                <property name="jobDetail" ref="beginAutoStagingJobDetail" />
                <!-- run every morning at 10:15 AM -->
                <property name="cronExpression" value="0 15 10 ? * *" />
                </bean>

                <bean id="SchedulerFactory"
                class="org.springframework.scheduling.quartz.Sched ulerFactoryBean"
                lazy-init="false">
                <property name="triggers">
                <list>
                <ref bean="SchedulerTrigger" />
                <ref bean="cronTrigger" />
                </list>
                </property>
                </bean>
                Last edited by slayer; Jun 17th, 2009, 06:56 AM.

                Comment


                • #9
                  class cast exception while creating SchedulerFactoryBean

                  Hi all,
                  I am getting class cast exception when i am creating instance using bean file.
                  My bean file is
                  <bean id="schedulerFactory" class="org.springframework.scheduling.quartz.Sched ulerFactoryBean">
                  <property name="startupDelay" value="30" />
                  <property name="waitForJobsToCompleteOnShutdown" value="true" />
                  </bean>

                  <code>
                  schedulerFactory = ac.getBean("schedulerFactory");
                  schedulerFactory.setTriggers((getJobTriggers(jobsM etaData))
                  .toArray(new Trigger[1]));
                  schedulerFactory.afterPropertiesSet();
                  <code>

                  This gives me following exception.
                  Exception in thread "main" java.lang.ClassCastException: org.quartz.impl.StdScheduler
                  at com.t5c.batch.BatchJobScheduler.createAndRunSchedu ler(BatchJobScheduler.java:152)
                  at com.t5c.batch.BatchJobScheduler.start(BatchJobSche duler.java:90)
                  at com.t5c.batch.test.MainTest.main(MainTest.java:8)
                  Tell me what is the workaround please.
                  Regards

                  Comment

                  Working...
                  X