使用任务调度报错

严重: Exception starting filter jfinal
java.lang.NoClassDefFoundError: it/sauronsoftware/cron4j/Scheduler
    at com.jfinal.plugin.cron4j.Cron4jPlugin$TaskInfo.schedule(Cron4jPlugin.java:255)
    at com.jfinal.plugin.cron4j.Cron4jPlugin.start(Cron4jPlugin.java:216)
    at com.jfinal.core.Config.startPlugins(Config.java:107)
    at com.jfinal.core.Config.configJFinal(Config.java:53)
    at com.jfinal.core.JFinal.init(JFinal.java:63)
    at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)
    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4855)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5549)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1263)
    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1948)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: it.sauronsoftware.cron4j.Scheduler
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1722)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1573)
    ... 22 more

maven引入了

<dependency>
    <groupId>it.sauronsoftware.cron4j</groupId>
    <artifactId>cron4j</artifactId>
    <version>2.2.5</version>
</dependency>

configPlugin配置了

Cron4jPlugin cp = new Cron4jPlugin();
//没分钟执行一次
cp.addTask("* * * * *", new MyTaskController());
me.add(cp);

MyTaskController实现了Runnable

使用tomcat7启动的,想问一下遗漏了什么报的错

评论区

JFinal

2018-01-29 18:12

百度搜索一下:NoClassDefFoundError

好多解决办法,这个是 java 开发基础,与具体哪项技术是无关的

toBeMN

2018-01-29 18:17

解决了,需要Java Build Path的Order and Export勾选上

红安啊

2020-10-16 16:58

@toBeMN 好难解决不了,太痛苦了

JFinal

2020-10-16 17:33

@红安啊 java 基础这一关必须要自己过掉,任何人都帮不上忙

羊羊羊羊

2021-10-22 10:56

我也被这个困扰了好久,然后把的provided注掉就行了

热门反馈

扫码入社