So I have a perfectly working quartz job as defined below:

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());

    }
}

Whenever I run the job in the quartz scheduler on the site, everything runs fine UNTIL it tries to run the JodaTime command.

It outputs the I REALLY HOPE THIS WORKS text, but after that I get this stack trace:

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

I am trying to run code from a different external library that I wrote myself. The whole project is managed using maven. I am simply using JodaTime as a test to make sure/see if it will run code from an outside library.

有帮助吗?

解决方案

The problem is that you have compiled your sources with JodaTime libraries in your classpath, but they are not available in target classpath. Ensure they are in your app server's lib directory or include them in your artifact.

其他提示

You have to have a "libs/" folder in your project directory, with the jar inside it ; is it the case ?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top