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

  • ScheduledTimerTask Issue

    Hi Guys,

    I've set up a ScheduledTimeTask With a TimerFactory to kick everything off any its running without issue. Basically the task at the minute prints out a message but by problem is the message gets printed twice everytime the run() method is called. Does anyone have any ideas why this is ?

    Code:
    	<bean id="db-loader-task" class="com.web.scheduler.task.DatabaseLoaderViaXmlTask" />
    	
    	<bean id="db-timer-task" class="org.springframework.scheduling.timer.ScheduledTimerTask">
    		<property name="delay" value="20000"/>
    		<property name="period" value="10000"/>
    		<property name="timerTask" ref="db-loader-task"/>
    	</bean>
    	
    	<bean id="db-timer-factory" class="org.springframework.scheduling.timer.TimerFactoryBean">
    		<property name="scheduledTimerTasks">
    			<list>
    				<ref bean="db-timer-task"/>
    			</list>
    		</property>
    	</bean>
    Code:
    public class DatabaseLoaderViaXmlTask extends TimerTask {
    
    	@Override
    	public void run() {
    		System.out.println(".................Timer task kick off................");
    		return;
    	}
    
    }

  • #2
    My guess is your configuration is loaded twice.

    Comment


    • #3
      I don't understand how it's possible for configuration to be loaded twice ?

      I have a single web.xml, single servlet.xml and a single security.xml. Also the application is only deployed once, at least there is only once instance deployed in Eclipse. I've got Tomcat 5.5 running in that...

      Comment


      • #4
        OK it certainly does look like the configuration is loading twice as I've now seen it in other beans within the servlet.xml but I still don't understand how a config can be loaded twice ?

        Comment


        • #5
          Found the error !

          Using Tomcat inside eclipse will start 2 instances if your content path and project are named differently. Naming these the same thing only causes the servlets etc to be initialized once

          Comment

          Working...
          X