-
Sep 21st, 2006, 06:48 AM
#1
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">
<list>
<value>test@springframework.org</value>
<value>foo@bar.com</value>
<value>john@doe.net</value>
</list>
</property>
</bean>
<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>
<bean id="doIt" class="org.springframework.scheduling.timer.Method InvokingTimerTaskFactoryBean">
<property name="targetObject" ref="exampleBusinessObject" />
<property name="targetMethod" value="doIt" />
</bean>
<bean id="timerFactory" class="org.springframework.scheduling.timer.TimerF actoryBean">
<property name="scheduledTimerTasks">
<list>
<!-- see the example above -->
<ref bean="scheduledTask" />
</list>
</property>
</bean>
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(BeanWrapperImpl.java:951)
Thanks in Advance
Abhijeet
-
Sep 21st, 2006, 07:59 AM
#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?
Bill
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules