netbeans java.lang.ClassNotFoundException:org.quartz.不允许并发执行

g0czyy6m  于 2022-11-24  发布在  Java
关注(0)|答案(4)|浏览(154)

我开发了一些执行quartz作业的代码,最初代码在tomcat之外,执行得很好,但当我试图将相同的代码嵌入到Web应用程序中时,我得到了java.lang.NoClassDefFoundError:org/quartz/DisallowConcurrentExecution。我使用的是quartz 2.1.5,它已经在类路径中了。下面是堆栈跟踪:

Exception in thread "DefaultQuartzScheduler_QuartzSchedulerThread" java.lang.NoClassDefFoundError: org/quartz/DisallowConcurrentExecution
INFO: Illegal access: this web application instance has been stopped already.  Could not load org.quartz.DisallowConcurrentExecution.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
        at org.quartz.impl.JobDetailImpl.isConcurrentExectionDisallowed(JobDetailImpl.java:390)
java.lang.IllegalStateException
        at org.quartz.simpl.RAMJobStore.acquireNextTriggers(RAMJobStore.java:1447)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1273)
        at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:264)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
Caused by: java.lang.ClassNotFoundException: org.quartz.DisallowConcurrentExecution
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
        at org.quartz.impl.JobDetailImpl.isConcurrentExectionDisallowed(JobDetailImpl.java:390)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
        at org.quartz.simpl.RAMJobStore.acquireNextTriggers(RAMJobStore.java:1447)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:264)
p8ekf7hl

p8ekf7hl1#

确保类路径中只有1个quartz-all-.jar(可能有2:Tomcat lib文件夹中的1个+war中的1个)

hmtdttj4

hmtdttj42#

NoClassDefFoundError指向类路径上缺少的JAR或类。在这种情况下,问题可能是在Tomcat中,类路径上有quartz-<ver>.jar,而实际上需要quartz-all-<ver>.jar

2ledvvac

2ledvvac3#

使用Maven的用户可以通过添加

<dependency>
        <groupId>org.quartz-scheduler</groupId>
        <artifactId>quartz</artifactId>
        <version>2.1.7</version>
    </dependency>
cgvd09ve

cgvd09ve4#

它应该是将.jar文件保留在项目位置内.从项目所在位置外部导入.jar文件是出现此错误的原因。还验证了如果项目是Maven项目,则应在pom.xml中包含Maven依赖项,以便将依赖项添加到项目中

<dependency>
   <groupId>org.quartz-scheduler</groupId>
   <artifactId>quartz</artifactId>
   <version>2.3.2</version>
</dependency>
<dependency>
   <groupId>org</groupId>
   <artifactId>quartz_job</artifactId>
   <version>2.2.1</version>
</dependency>

相关问题