Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Spring exception while using quartz in web app

  1. #1
    Join Date
    Apr 2007
    Posts
    22

    Default Spring exception while using quartz in web app

    Hi,

    While loading the scheduler through the web app, application is throwing the below error.
    2007-05-29 19:41:16,567 ERROR [org.springframework.web.context.ContextLoader] - Context initialization failed
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'scheduler' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'cronProperties' while setting bean property 'jobDetail'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'cronProperties' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'jobDetail1' while setting bean property 'jobDetail'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'jobDetail1' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodException: java.lang.String.run()
    Caused by:
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'cronProperties' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'jobDetail1' while setting bean property 'jobDetail'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'jobDetail1' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodException: java.lang.String.run()
    Caused by:
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'jobDetail1' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodException: java.lang.String.run()
    Caused by:
    java.lang.NoSuchMethodException: java.lang.String.run()
    at java.lang.Class.getMethod(Class.java:1581)


    Properties
    Code:
    web.xml
    
    <!-- Leave the listener commented-out if using JBoss -->
    	
         	<listener>
    		<listener-class>
    org.springframework.web.context.ContextLoaderListener
    </listener-class>
    	</listener>
    	
    
    
    --------------------------	
    applicationcontext.xml
    
    <beans>
    
    	<!-- Quartz Scheduler, with pre-registered triggers -->
    	<!-- Will automatically start scheduling on context startup -->
    	<bean name="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    	<property name="jobDetail" ref="cronProperties" />
    	</bean>
     
    	<!-- Trigger for the job defined above -->
    	<!-- Registered by the 'scheduler' bean -->
    	<bean id="cronProperties" class="org.springframework.scheduling.quartz.CronTriggerBean">
    		<property name="jobDetail" ref="jobDetail1"/>
    		<property name="cronExpression" value="0/5 * * * * ?"/>
    	</bean>
    	
    <bean id="jobDetail1" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
      <property name="targetObject" value="com.elift.component.scheduler.job.JobActiveAssociateMail" />
      <property name="targetMethod" value="run" />
    </bean>
    
    
    ----------------
    Java code
    
    	public class JobActiveAssociateMail {
    
    //	protected void executeInternal(JobExecutionContext arg0) throws JobExecutionException {
    //		System.out.println("Scheduler started");
    //	
    //	}
    	public void run(){
    		System.out.println("Scheduler started");
    	}
    	
    }

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    Your definition is wrong. You have specified a targetObject with a value whereas it should be a ref or instead of a targetObject specify a targetClass.

    Code:
    <bean id="jobDetail1" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
      <property name="targetObject" value="com.elift.component.scheduler.job.JobActiveAssociateMail" />
      <property name="targetMethod" value="run" />
    </bean>
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Apr 2007
    Posts
    22

    Default

    Thanks for the reply
    i changed it to ref but still the error persists

    applicationcontext.xml looks like this
    Code:
    <bean id="javaJob" class="com.elift.component.scheduler.job.JobActiveAssociateMail"/>
    	
    <bean id="jobDetail1" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
      <property name="targetObject"  ref="javaJob"/>
      <property name="targetMethod" value="run" />
    </bean>
    2007-05-29 19:41:16,567 ERROR [org.springframework.web.context.ContextLoader] - Context initialization failed
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'scheduler' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'cronProperties' while setting bean property 'jobDetail'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'cronProperties' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'jobDetail1' while setting bean property 'jobDetail'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'jobDetail1' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodException: java.lang.String.run()
    Caused by:
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'cronProperties' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'jobDetail1' while setting bean property 'jobDetail'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'jobDetail1' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodException: java.lang.String.run()
    Caused by:
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'jobDetail1' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodException: java.lang.String.run()
    Caused by:
    java.lang.NoSuchMethodException: java.lang.String.run()
    at java.lang.Class.getMethod(Class.java:1581)

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    Make sure that your configuration is being deployed and loaded correctly. Your configuration looks fine for as far as I can see.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5
    Join Date
    Apr 2007
    Posts
    22

    Default

    I am using tomcat to configure the scheduler.
    Apart from changing the web.xml file i think there is no extra configuration to run an application.

    My Jsp/HTML pages are coming up if i comment out the Context listener in the web.xml.

    And i am able to run the quartz on the standalone

  6. #6
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,425

    Default

    That seems like quite a strange error. Is it possible to see the rest of the quartz related configuration you are using?
    Last edited by karldmoore; Aug 30th, 2007 at 06:00 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  7. #7
    Join Date
    Apr 2007
    Posts
    22

    Default

    I believe that spring provides the quartz configuration in the xml itself.
    So i didn't do any extra settings.
    I configured in applicationcontext.xml only.
    applicationcontext.xml looks like this

    Code:
    <bean name="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    	<property name="jobDetail" ref="cronProperties" />
    	</bean>
    
    
    
    	<bean id="cronProperties" class="org.springframework.scheduling.quartz.CronTriggerBean">
    		<property name="jobDetail" ref="jobDetail1"/>
    		<property name="cronExpression" value="0/5 * * * * ?"/>
    	</bean>
    <bean id="javaJob" class="com.elift.component.scheduler.job.JobActiveAssociateMail"/>
    	
    <bean id="jobDetail1" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
      <property name="targetObject"  ref="javaJob"/>
      <property name="targetMethod" value="run" />
    </bean>

    let me know if i missed anything in the configuration

  8. #8
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,425

    Default

    I'm not too sure about the SchedulerFactoryBean configuration, I think it should look like this.
    Code:
    <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="triggers">
            <list>
                <ref bean="cronProperties" />
            </list>
        </property>
    </bean>
    I've just noticed that you talk about configuring Quartz through tomcat? Don't you just want to configure Quartz via the SchedulerFactoryBean?
    http://www.springframework.org/docs/...ctoryBean.html
    Last edited by karldmoore; Aug 30th, 2007 at 06:00 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  9. #9
    Join Date
    Apr 2007
    Posts
    22

    Default

    As you said i added the list tag to the properties
    and my applicationcontext looks like this. Different exception generated
    Code:
    	<bean name="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    	<property name="jobDetail"  />
    		<property name="triggers">
    			<list>
    				<ref bean="cronProperties"/>
    			</list>
    		</property> 
    	</bean>
     
    	<!-- Trigger for the job defined above -->
    	<!-- Registered by the 'scheduler' bean -->
    	<bean id="cronProperties" class="org.springframework.scheduling.quartz.CronTriggerBean">
    		<property name="jobDetail" ref="jobMethod"/>
    		<property name="cronExpression" value="0/5 * * * * ?"/>
    	</bean>
    <bean id="javaJob" class="com.elift.component.scheduler.job.JobActiveAssociateMail"/>
    	
    <bean id="jobMethod" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
      <property name="targetObject"  ref="javaJob"/>
      <property name="targetMethod" value="run" />
    </bean>

    2007-05-30 18:07:06,495 ERROR [org.springframework.web.context.ContextLoader] - Context initialization failed
    org.springframework.beans.factory.parsing.BeanDefi nitionParsingException: Configuration problem: Unexpected failure during bean definition parsing
    Offending resource: ServletContext resource [/WEB-INF/applicationContext.xml]
    Bean 'scheduler'; nested exception is org.springframework.beans.factory.parsing.BeanDefi nitionParsingException: Configuration problem: <property> element for property 'jobDetail' must specify a ref or value
    Offending resource: ServletContext resource [/WEB-INF/applicationContext.xml]
    Bean 'scheduler'
    -> Property 'jobDetail'
    Caused by:
    org.springframework.beans.factory.parsing.BeanDefi nitionParsingException: Configuration problem: <property> element for property 'jobDetail' must specify a ref or value
    Offending resource: ServletContext resource [/WEB-INF/applicationContext.xml]
    Bean 'scheduler'
    -> Property 'jobDetail'
    at org.springframework.beans.factory.parsing.FailFast ProblemReporter.error(FailFastProblemRepo

  10. #10
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,425

    Default

    You've not copied the example exactly though.
    Code:
    	<bean name="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    	<property name="jobDetail"  />
    		<property name="triggers">
    			<list>
    				<ref bean="cronProperties"/>
    			</list>
    		</property> 
    	</bean>
    Code:
    	<bean name="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    		<property name="triggers">
    			<list>
    				<ref bean="cronProperties"/>
    			</list>
    		</property> 
    	</bean>
    Last edited by karldmoore; Aug 30th, 2007 at 05:59 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •