Hi,
I've read many posts on this forum regarding this issue, but still can't solve my problem.
Basically, I have one scheduled task in a Spring + MVC project and the task is executing twice. Below are the relevant sections of web.xml, etc.
Any help will be much appreciated. Thanks.
web.xml
root-context.xmlCode:<context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring/root-context.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>myapp</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring/myServlet/servlet-context.xml</param-value> </init-param> </servlet> <filter> <filter-name>securityFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> <init-param> <param-name>targetBeanName</param-name> <param-value>springSecurityFilterChain</param-value> </init-param> </filter> <filter-mapping> <filter-name>securityFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
servlet-context.xmlCode:<context:annotation-config /> <import resource="security.xml" /> <context:component-scan base-package="com.myapp" /> <bean id="myTask" class="com.myapp.tasks.MyTask" /> <task:scheduled-tasks> <!-- run once a minute (for development) --> <task:scheduled ref="myTask" method="doSync" cron="0 * * * * ?" /> </task:scheduled-tasks>
controllers.xmlCode:<mvc:annotation-driven/> <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources/ directory --> <resources mapping="/resources/**" location="/resources/" /> <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/pages directory --> <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <beans:property name="prefix" value="/WEB-INF/pages/" /> <beans:property name="suffix" value=".jsp" /> </beans:bean>
Code:<context:annotation-config /> <context:component-scan base-package="com.myapp.web" />


Reply With Quote
