Announcement Announcement Module
Collapse
No announcement yet.
Problems with Timers Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems with Timers

    Hi,

    after successfully using the timer functionality in Spring to call a method (by creating a TimerTask) , I came across the convience class MethodInvokingTimerTaskfactoryBean.

    However, I cannot get it to work. Here's my xml:

    Code:
    <bean id="scheduledDBCheckTask" class="org.springframework.scheduling.timer.MethodInvokingTimerTaskFactoryBean">
    		<property name="targetObject">
    			<ref bean="queryService"/>			
    		</property>
    		<property name="targetMethod">
    			<value>checkQueryCompleted</value>			
    		</property>
    	</bean>
    	
    	<bean class="org.springframework.scheduling.timer.TimerFactoryBean">
    		<property name="scheduledTimerTasks">
    			<list>
    				<ref bean="scheduledDBCheckTask"/>				
    			</list>			
    		</property>		
    	</bean>
    I seem to have lost the timer info (it needs to run every 10 seconds). Here's my error:

    Code:
    2500  ERROR 2005-04-27 11&#58;40&#58;15,975 &#91;httpWorkerThread-4848-2&#93; context.ContextLoader - Context initialization failed
    org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'org.springframework.scheduling.timer.TimerFactoryBean' defined in ServletContext resource &#91;/WEB-INF/pbtv-service.xml&#93;&#58; Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptionsException&#58; PropertyAccessExceptionsException &#40;1 errors&#41;; nested propertyAccessExceptions are&#58; &#91;org.springframework.beans.TypeMismatchException&#58; Failed to convert property value of type &#91;org.springframework.scheduling.timer.MethodInvokingTimerTaskFactoryBean$MethodInvokingTimerTask&#93; to required type &#91;org.springframework.scheduling.timer.ScheduledTimerTask&#93; for property 'scheduledTimerTasks&#91;0&#93;'&#93;
    PropertyAccessExceptionsException &#40;1 errors&#41;
    org.springframework.beans.TypeMismatchException&#58; Failed to convert property value of type &#91;org.springframework.scheduling.timer.MethodInvokingTimerTaskFactoryBean$MethodInvokingTimerTask&#93; to required type &#91;org.springframework.scheduling.timer.ScheduledTimerTask&#93; for property 'scheduledTimerTasks&#91;0&#93;'
            at org.springframework.beans.BeanWrapperImpl.doTypeConversionIfNecessary&#40;BeanWrapperImpl.java&#58;1016&#41;
            at org.springframework.beans.BeanWrapperImpl.doTypeConversionIfNecessary&#40;BeanWrapperImpl.java&#58;982&#41;
            at org.springframework.beans.BeanWrapperImpl.setPropertyValue&#40;BeanWrapperImpl.java&#58;779&#41;
            at org.springframework.beans.BeanWrapperImpl.setPropertyValue&#40;BeanWrapperImpl.java&#58;685&#41;
            at org.springframework.beans.BeanWrapperImpl.setPropertyValue&#40;BeanWrapperImpl.java&#58;826&#41;
            at org.springframework.beans.BeanWrapperImpl.setPropertyValues&#40;BeanWrapperImpl.java&#58;853&#41;
            at org.springframework.beans.BeanWrapperImpl.setPropertyValues&#40;BeanWrapperImpl.java&#58;842&#41;
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues&#40;AbstractAutowireCapableBeanFactory.java&#58;870&#41;
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean&#40;AbstractAutowireCapableBeanFactory.java&#58;688&#41;
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;325&#41;
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;260&#41;
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;221&#41;
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;145&#41;
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons&#40;DefaultListableBeanFactory.java&#58;285&#41;
            at org.springframework.context.support.AbstractApplicationContext.refresh&#40;AbstractApplicationContext.java&#58;317&#41;
            at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh&#40;AbstractRefreshableWebApplicationContext.java&#58;131&#41;
            at org.springframework.web.context.ContextLoader.createWebApplicationContext&#40;ContextLoader.java&#58;224&#41;
            at org.springframework.web.context.ContextLoader.initWebApplicationContext&#40;ContextLoader.java&#58;150&#41;
            at org.springframework.web.context.ContextLoaderListener.contextInitialized&#40;ContextLoaderListener.java&#58;48&#41;
            at org.apache.catalina.core.StandardContext.listenerStart&#40;StandardContext.java&#58;4010&#41;
            at org.apache.catalina.core.StandardContext.start&#40;StandardContext.java&#58;4522&#41;
            at com.sun.enterprise.web.WebModule.start&#40;WebModule.java&#58;241&#41;
            at org.apache.catalina.core.ContainerBase.addChildInternal&#40;ContainerBase.java&#58;827&#41;
            at org.apache.catalina.core.ContainerBase.access$000&#40;ContainerBase.java&#58;125&#41;
            at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run&#40;ContainerBase.java&#58;147&#41;
            at java.security.AccessController.doPrivileged&#40;Native Method&#41;
            at org.apache.catalina.core.ContainerBase.addChild&#40;ContainerBase.java&#58;809&#41;
            at org.apache.catalina.core.StandardHost.addChild&#40;StandardHost.java&#58;632&#41;
            at com.sun.enterprise.web.WebContainer.loadWebModule&#40;WebContainer.java&#58;1279&#41;
            at com.sun.enterprise.web.WebContainer.loadWebModule&#40;WebContainer.java&#58;1006&#41;
            at com.sun.enterprise.server.WebModuleDeployEventListener.moduleDeployed&#40;WebModuleDeployEventListener.java&#58;160&#41;
            at com.sun.enterprise.server.WebModuleDeployEventListener.moduleDeployed&#40;WebModuleDeployEventListener.java&#58;238&#41;
            at com.sun.enterprise.admin.event.AdminEventMulticaster.invokeModuleDeployEventListener&#40;AdminEventMulticaster.java&#58;918&#41;
            at com.sun.enterprise.admin.event.AdminEventMulticaster.handleModuleDeployEvent&#40;AdminEventMulticaster.java&#58;905&#41;
            at com.sun.enterprise.admin.event.AdminEventMulticaster.processEvent&#40;AdminEventMulticaster.java&#58;427&#41;
            at com.sun.enterprise.admin.event.AdminEventMulticaster.multicastEvent&#40;AdminEventMulticaster.java&#58;139&#41;
            at com.sun.enterprise.admin.server.core.DeploymentNotificationHelper.multicastEvent&#40;DeploymentNotificationHelper.java&#58;288&#41;
            at com.sun.enterprise.deployment.phasing.DeploymentServiceUtils.multicastEvent&#40;DeploymentServiceUtils.java&#58;155&#41;
            at com.sun.enterprise.deployment.phasing.ServerDeploymentTarget.sendStartEvent&#40;ServerDeploymentTarget.java&#58;258&#41;
            at com.sun.enterprise.deployment.phasing.StartPhase.runPhase&#40;StartPhase.java&#58;87&#41;
            at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase&#40;DeploymentPhase.java&#58;71&#41;
            at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases&#40;PEDeploymentService.java&#58;633&#41;
            at com.sun.enterprise.deployment.phasing.PEDeploymentService.start&#40;PEDeploymentService.java&#58;361&#41;
            at com.sun.enterprise.deployment.phasing.PEDeploymentService.start&#40;PEDeploymentService.java&#58;396&#41;
            at com.sun.enterprise.admin.mbeans.ApplicationsConfigMBean.start&#40;ApplicationsConfigMBean.java&#58;702&#41;
            at sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Native Method&#41;
            at sun.reflect.NativeMethodAccessorImpl.invoke&#40;NativeMethodAccessorImpl.java&#58;39&#41;
            at sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;DelegatingMethodAccessorImpl.java&#58;25&#41;
            at java.lang.reflect.Method.invoke&#40;Method.java&#58;324&#41;
            at com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean&#40;MBeanHelper.java&#58;302&#41;
            at com.sun.enterprise.admin.config.BaseConfigMBean.invoke&#40;BaseConfigMBean.java&#58;357&#41;
            at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke&#40;DynamicMetaDataImpl.java&#58;213&#41;
            at com.sun.jmx.mbeanserver.MetaDataImpl.invoke&#40;MetaDataImpl.java&#58;220&#41;
            at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke&#40;DefaultMBeanServerInterceptor.java&#58;815&#41;
            at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke&#40;JmxMBeanServer.java&#58;784&#41;
            at sun.reflect.GeneratedMethodAccessor23.invoke&#40;Unknown Source&#41;
            at sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;DelegatingMethodAccessorImpl.java&#58;25&#41;
            at java.lang.reflect.Method.invoke&#40;Method.java&#58;324&#41;
            at com.sun.enterprise.admin.util.proxy.ProxyClass.invoke&#40;ProxyClass.java&#58;54&#41;
            at $Proxy1.invoke&#40;Unknown Source&#41;
            at com.sun.enterprise.admin.server.core.jmx.SunoneInterceptor.invoke&#40;SunoneInterceptor.java&#58;272&#41;
            at com.sun.enterprise.admin.jmx.remote.server.callers.InvokeCaller.call&#40;InvokeCaller.java&#58;38&#41;
            at com.sun.enterprise.admin.jmx.remote.server.MBeanServerRequestHandler.handle&#40;MBeanServerRequestHandler.java&#58;92&#41;
            at com.sun.enterprise.admin.jmx.remote.server.servlet.RemoteJmxConnectorServlet.processRequest&#40;RemoteJmxConnectorServlet.java&#58;69&#41;
            at com.sun.enterprise.admin.jmx.remote.server.servlet.RemoteJmxConnectorServlet.doPost&#40;RemoteJmxConnectorServlet.java&#58;94&#41;
            at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;767&#41;
            at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;860&#41;
            at sun.reflect.GeneratedMethodAccessor67.invoke&#40;Unknown Source&#41;
            at sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;DelegatingMethodAccessorImpl.java&#58;25&#41;
            at java.lang.reflect.Method.invoke&#40;Method.java&#58;324&#41;
            at org.apache.catalina.security.SecurityUtil$1.run&#40;SecurityUtil.java&#58;249&#41;
            at java.security.AccessController.doPrivileged&#40;Native Method&#41;
            at javax.security.auth.Subject.doAsPrivileged&#40;Subject.java&#58;500&#41;
            at org.apache.catalina.security.SecurityUtil.execute&#40;SecurityUtil.java&#58;282&#41;
            at org.apache.catalina.security.SecurityUtil.doAsPrivilege&#40;SecurityUtil.java&#58;165&#41;
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter&#40;ApplicationFilterChain.java&#58;257&#41;
            at org.apache.catalina.core.ApplicationFilterChain.access$000&#40;ApplicationFilterChain.java&#58;55&#41;
            at org.apache.catalina.core.ApplicationFilterChain$1.run&#40;ApplicationFilterChain.java&#58;161&#41;
            at java.security.AccessController.doPrivileged&#40;Native Method&#41;
            at org.apache.catalina.core.ApplicationFilterChain.doFilter&#40;ApplicationFilterChain.java&#58;157&#41;
            at org.apache.catalina.core.StandardWrapperValve.invoke&#40;StandardWrapperValve.java&#58;263&#41;
            at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;551&#41;
            at org.apache.catalina.core.StandardContextValve.invokeInternal&#40;StandardContextValve.java&#58;225&#41;
            at org.apache.catalina.core.StandardContextValve.invoke&#40;StandardContextValve.java&#58;173&#41;
            at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;551&#41;
            at org.apache.catalina.core.StandardHostValve.invoke&#40;StandardHostValve.java&#58;161&#41;
            at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;551&#41;
            at org.apache.catalina.core.StandardEngineValve.invoke&#40;StandardEngineValve.java&#58;132&#41;
            at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;551&#41;
            at org.apache.catalina.core.ContainerBase.invoke&#40;ContainerBase.java&#58;933&#41;
            at org.apache.coyote.tomcat5.CoyoteAdapter.service&#40;CoyoteAdapter.java&#58;184&#41;
            at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process&#40;ProcessorTask.java&#58;653&#41;
            at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process&#40;ProcessorTask.java&#58;534&#41;
            at com.sun.enterprise.web.connector.grizzly.ProcessorTask.doTask&#40;ProcessorTask.java&#58;403&#41;
            at com.sun.enterprise.web.connector.grizzly.WorkerThread.run&#40;WorkerThread.java&#58;55&#41;
    Any idea what the problem is?

    Thanks

    Rakesh

  • #2
    ok, got it working - hard keeping track of all these references!!

    Code:
    	<bean id="methodInvokingTask" class="org.springframework.scheduling.timer.MethodInvokingTimerTaskFactoryBean">
    		<property name="targetObject">
    			<ref local="queryService"/>
    		</property>
    		<property name="targetMethod">
    			<value>checkQueryCompleted</value>
    		</property>
    	</bean>
    	
    	<bean id="scheduledTask" class="org.springframework.scheduling.timer.ScheduledTimerTask">
    	<!-- wait 10 seconds before starting repeated execution -->
    		<property name="delay">
    			<value>10000</value>
    		</property>
    		<!-- run every 50 seconds -->
    		<property name="period">
    			<value>5000</value>
    		</property>
    		<property name="timerTask">
    			<ref local="methodInvokingTask"/>
    		</property>
    	</bean>
    	
    	<bean class="org.springframework.scheduling.timer.TimerFactoryBean">
    		<property name="scheduledTimerTasks">
    			<list>
    				<ref bean="scheduledTask"/>				
    			</list>			
    		</property>		
    	</bean>

    Comment

    Working...
    X