Announcement Announcement Module
No announcement yet.
Spring schedular problems Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring schedular problems

    Dear All

    I want to execute a task using spring support for schedular.
    I have tried with Quartz Scheduler and JDK Timer but in bothe cases I am getting similar exception,
    My bean definations are..

    <bean id="checkEmail" class="schedular.CheckEmailAddresses">
    <property name="emailAddresses">
    <value>[email protected]</value>
    <value>[email protected]</value>
    <value>[email protected]</value>

    <bean id="exampleBusinessObject" class="schedular.ExampleBusinessObject"/>

    <bean id="scheduledTask" class="org.springframework.scheduling.timer.Schedu ledTimerTask">
    <!-- wait 10 seconds before starting repeated execution -->
    <property name="delay" value="10000" />
    <!-- run every 50 seconds -->
    <property name="period" value="50000" />
    <property name="timerTask" ref="checkEmail" />

    <bean id="doIt" class="org.springframework.scheduling.timer.Method InvokingTimerTaskFactoryBean">
    <property name="targetObject" ref="exampleBusinessObject" />
    <property name="targetMethod" value="doIt" />


    <bean id="timerFactory" class="org.springframework.scheduling.timer.TimerF actoryBean">
    <property name="scheduledTimerTasks">
    <!-- see the example above -->
    <ref bean="scheduledTask" />

    While staring server I have following exception

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'scheduledTask' defined in ServletContext resource [/WEB-INF/classes/spring-service-context.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptions Exception: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy137] to required type [java.util.TimerTask] for property 'timerTask']
    PropertyAccessExceptionsException (1 errors)
    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy137] to required type [java.util.TimerTask] for property 'timerTask'
    at org.springframework.beans.BeanWrapperImpl.doTypeCo nversionIfNecessary(

    Thanks in Advance


  • #2
    According to the exception checkEmail is a proxy, not a subclass of TimerTask. Since TimerTask isn't an interface its an abstract class, it can't be used proxied using SDK proxies, but CGLIB. Is an autoproxy being applied to your checkEmail by any chance? If this is your exact application context, I see no reason why checkEmail should be a proxy.

    Could you post the source for schedular.CheckEmailAddresses.

    As a side note, I would expect scheduledTask to take the doIt object, since that bean is a TimerTask, but in this example its not even used. And come to think of it neither is exampleBusinessObject. And these just extra objects used for something else in your application?