bena装载spring定时器时出问题
这是我在web-inf/springtimer.xml中的信息
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"> <bean id="timer" class="com.timeftp.Timer"> <property name="invoketf" value="true"/> </bean> <bean id="reportTask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject" ref="timer" /> <property name="targetMethod" value="callFTP" /> <property name="concurrent" value="false" /> </bean> <bean id="cronTigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> <property name="jobDetail" ref="reportTask" /> <property name="cronExpression" value="0 0 23 * * ?"/> </bean> <bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref bean="cronTigger"/> </list> </property> </bean></beans>
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/springtimer.xml</param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener></web-app>
package com.timeftp;import com.ftpconnect.FtpID;import com.ftpconnect.FtpTest;public class Timer { private boolean invoketf; /** * 连接FTP文件下载删除 */ public void callFTP() { FtpID fid = new FtpID(); System.out.println("自动开始"); fid.inject("ftp.properties"); FtpTest.loginFTP(fid.getftp(), fid.getPost(), fid.getUser(), fid .getPassword()); FtpTest.downfile(fid.getFilepath()); FtpTest.deleteFile(); FtpTest.closeFTP(); System.out.println("自动结束"); } /** * TOMCAT启动时是否立即在FTP上下载文件和删除文件 * @param invoketf */ public void setInvoketf(boolean invoketf) { this.invoketf = invoketf; if (this.invoketf) { FtpID fid = new FtpID(); fid.inject("ftp.properties"); if (fid.isTf()) { System.out.println("TOMCAT启动立即下载开始"); FtpTest.loginFTP(fid.getftp(), fid.getPost(), fid.getUser(), fid.getPassword()); FtpTest.downfile(fid.getFilepath()); FtpTest.deleteFile(); FtpTest.closeFTP(); System.out.println("TMOCAT启动立即下载结束"); } } }}
2012-4-9 15:42:51 org.apache.catalina.core.AprLifecycleListener init信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\Javasoft\MyEclipse 6.0\bin;D:\Javasoft\tomcat-6.0.29\bin2012-4-9 15:42:51 org.apache.coyote.http11.Http11Protocol init信息: Initializing Coyote HTTP/1.1 on http-80802012-4-9 15:42:51 org.apache.catalina.startup.Catalina load信息: Initialization processed in 1155 ms2012-4-9 15:42:52 org.apache.catalina.core.StandardService start信息: Starting service Catalina2012-4-9 15:42:52 org.apache.catalina.core.StandardEngine start信息: Starting Servlet Engine: Apache Tomcat/6.0.292012-4-9 15:42:52 org.apache.catalina.startup.HostConfig deployDescriptor信息: Deploying configuration descriptor host-manager.xml2012-4-9 15:42:52 org.apache.catalina.startup.HostConfig deployDescriptor信息: Deploying configuration descriptor manager.xml2012-4-9 15:42:52 org.apache.catalina.startup.HostConfig deployDirectory信息: Deploying web application directory docs2012-4-9 15:42:53 org.apache.catalina.startup.HostConfig deployDirectory信息: Deploying web application directory examples2012-4-9 15:42:53 org.apache.catalina.core.ApplicationContext log信息: ContextListener: contextInitialized()2012-4-9 15:42:53 org.apache.catalina.core.ApplicationContext log信息: SessionListener: contextInitialized()2012-4-9 15:42:53 org.apache.catalina.startup.HostConfig deployDirectory信息: Deploying web application directory ROOT2012-4-9 15:42:53 org.apache.catalina.startup.HostConfig deployDirectory信息: Deploying web application directory springftp2012-4-9 15:42:54 org.apache.catalina.core.ApplicationContext log信息: Initializing Spring root WebApplicationContextlog4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).log4j:WARN Please initialize the log4j system properly.2012-4-9 15:42:55 org.apache.catalina.core.StandardContext listenerStart严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.timeftp.Timer] for bean with name 'time' defined in ServletContext resource [/WEB-INF/springtimer.xml]; nested exception is java.lang.ClassNotFoundException: com.timeftp.Timer at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1141) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:524) at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1177) at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:758) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:422) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:785) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445) at org.apache.catalina.core.StandardService.start(StandardService.java:519) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:581) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)Caused by: java.lang.ClassNotFoundException: com.timeftp.Timer at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491) at org.springframework.util.ClassUtils.forName(ClassUtils.java:211) at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:385) at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1138) ... 33 more2012-4-9 15:42:55 org.apache.catalina.core.StandardContext start严重: Error listenerStart2012-4-9 15:42:55 org.apache.catalina.core.StandardContext start严重: Context [/springftp] startup failed due to previous errors2012-4-9 15:42:55 org.apache.catalina.core.ApplicationContext log信息: Closing Spring root WebApplicationContext