1

所以我有一个完美的石英工作,定义如下:

package willkara.monkai.jobber;

import java.util.Date;
import org.joda.time.DateTime;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import willkara.monkai.impl.MonKaiClientImpl;


/* this is a test Quartz job to show that we can inject jobs into the jobscheduler from an external location */
public class tester implements Job {

    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        System.out.println("I REALLY HOPE THIS WORKS");
        DateTime dt = new DateTime();

        System.out.println(dt.getDayOfYear());

    }
}

每当我在站点上的石英调度程序中运行作业时,一切都运行良好,直到它尝试运行 JodaTime 命令。

它输出 I REALLY HOPE THIS WORKS 文本,但之后我得到了这个堆栈跟踪:

I REALLY HOPE THIS WORKS
2013-11-13 14:31:16,180 ERROR QuartzScheduler_Worker-1 org.quartz.core.JobRunShell - Job DEFAULT.qqq threw an unhandled Exception:
java.lang.NoClassDefFoundError: org/joda/time/DateTime
    at willkara.monkai.jobber.tester.execute(tester.java:16)
    at org.sakaiproject.component.app.scheduler.jobs.SpringJobBeanWrapper.execute(SpringJobBeanWrapper.java:70)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:534)
Caused by: java.lang.ClassNotFoundException: org.joda.time.DateTime
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 4 more
2013-11-13 14:31:16,183 ERROR QuartzScheduler_Worker-1 org.quartz.core.ErrorLogger - Job (DEFAULT.qqq threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.NoClassDefFoundError: org/joda/time/DateTime]
    at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:534)
Caused by: java.lang.NoClassDefFoundError: org/joda/time/DateTime
    at willkara.monkai.jobber.tester.execute(tester.java:16)
    at org.sakaiproject.component.app.scheduler.jobs.SpringJobBeanWrapper.execute(SpringJobBeanWrapper.java:70)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
    ... 1 more
Caused by: java.lang.ClassNotFoundException: org.joda.time.DateTime
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 4 more

我正在尝试从我自己编写的不同外部库运行代码。整个项目使用 maven 进行管理。我只是使用 JodaTime 作为测试来确保/查看它是否会运行来自外部库的代码。

4

2 回答 2

2

问题是您已经在类路径中使用 JodaTime 库编译了源代码,但它们在目标类路径中不可用。确保它们位于您的应用服务器的 lib 目录中或将它们包含在您的工件中。

于 2013-11-13T20:10:10.517 回答
1

您必须在项目目录中有一个“libs/”文件夹,其中包含 jar;是这样吗?

于 2013-11-13T20:07:37.680 回答