使用Quartz Scheduler for Jobs

时间:2017-12-21 09:49:57

标签: tomcat java-ee quartz-scheduler

你好我刚开始使用Quartz Scheduler,我按照这里的说明操作: https://dzone.com/articles/quartz-scheduler-configuration-for-web-application

首先,我将依赖项添加到我的pom.xml文件中:

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

然而,当我启动tomcat时,我的应用程序无法加载,我在日志中收到此错误:

  

将上下文初始化事件发送到侦听器实例的异常   class [org.quartz.ee.servlet.QuartzInitializerListener]   java.lang.NoClassDefFoundError:javax / transaction / UserTransaction at   java.lang.Class.getDeclaredMethods0(Native Method)at   java.lang.Class.privateGetDeclaredMethods(Class.java:2701)at at   java.lang.Class.privateGetPublicMethods(Class.java:2902)at at   java.lang.Class.getMethods(Class.java:1615)at   java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1336)     在   java.beans.Introspector.getTargetMethodInfo(Introspector.java:1197)     在java.beans.Introspector.getBeanInfo(Introspector.java:426)at   java.beans.Introspector.getBeanInfo(Introspector.java:173)at   org.quartz.impl.StdSchedulerFactory.setBeanProps(StdSchedulerFactory.java:1393)     在   org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:1057)     在   org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1519)     在   org.quartz.ee.servlet.QuartzInitializerListener.contextInitialized(QuartzInitializerListener.java:171)     在   org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4643)     在   org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5105)     在   org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)     在   org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1425)     在   org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1415)     在java.util.concurrent.FutureTask.run(FutureTask.java:266)at   org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)     在   java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)     在   org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941)     在   org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:839)     在   org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)     在   org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1425)     在   org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1415)     在java.util.concurrent.FutureTask.run(FutureTask.java:266)at   org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)     在   java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)     在   org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941)     在   org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:258)     在   org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)     在   org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)     在   org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)     在   org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:770)     在   org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)     在org.apache.catalina.startup.Catalina.start(Catalina.java:671)at   sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     在java.lang.reflect.Method.invoke(Method.java:498)at   org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:353)at at   org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:493)导致   by:java.lang.ClassNotFoundException:   javax.transaction.UserTransaction at   org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1275)     在   org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1104)     ......还有42个

     

2017年12月21日上午9:40:08 org.apache.catalina.core.StandardContext   startInternal SEVERE:一个或多个侦听器无法启动。充分   详细信息将在12月21日的相应容器日志文件中找到,   2017 9:40:08 AM org.apache.catalina.core.StandardContext startInternal   严重:由于先前的错误,上下文[/ enshika]启动失败   21,2017 9:40:08 AM org.apache.coyote.AbstractProtocol start INFO:   启动ProtocolHandler [&#34; http-nio-8080&#34;] 2017年12月21日上午9:40:08   org.apache.coyote.AbstractProtocol start INFO:Starting   ProtocolHandler [&#34; ajp-nio-8009&#34;] 2017年12月21日上午9:40:08   org.apache.catalina.startup.Catalina启动INFO:服务器启动   16141 ms

我按照说明将其添加到我的web.xml文件中:

<listener>
    <listener-class>
        org.quartz.ee.servlet.QuartzInitializerListener
    </listener-class>
</listener>

我创建了一个quartz.properties文件和一个quartz-jobs.xml文件,并将它们放在我的src / main / webapp / WEB-INF / classes目录中。

0 个答案:

没有答案