开发者

How to enable Quartz scheduling in Jboss AS 7.0?

Quartz doesn't appear to be included with the default install of Jboss AS 7.0 Final (full). Deployment of my EAR appears to fail when the Message Driven Bean (MDB) "FareMonitorBean" is attempted to be loaded. This MDB is what the quartz schedule executes.

Error message:

10:00:34,034 WARN  [org.jboss.modules] (MSC service thread 1-7) Failed to define class com.myproject.beans.FareMonitorBean in Module "deployment.myprojectEAP.ear.myprojectE开发者_StackOverflow中文版JB.jar:main" from Service Module Loader: java.lang.LinkageError: Failed to link com/myproject/beans/FareMonitorBean (Module "deployment.myprojectEAP.ear.myprojectEJB.jar:main" from Service Module Loader)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:401)
.....
Caused by: java.lang.NoClassDefFoundError: org/quartz/Job
at java.lang.ClassLoader.defineClass1(Native Method) [:1.6.0_26]
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) [:1.6.0_26]
at java.lang.ClassLoader.defineClass(ClassLoader.java:615) [:1.6.0_26]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) [:1.6.0_26]
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:397)
... 18 more

Summary of MDB "FareMonitorBean" class file :

@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "cronTrigger", propertyValue = EJBConstants.FARE_MONITOR_QUARTZ_SCHEDULE_STRING) })
@ResourceAdapter("quartz-jboss-2.0.2.jar")
public class FareMonitorBean implements Job {

    public void execute(JobExecutionContext arg0) throws JobExecutionException {
        ....
    }
}

Based on the JBoss documentation, my guess is that an "Extension" and "Subsystem" needs to be configured for Quartz in standalone/configuration/standalone.xml, however I'm not sure how to do this. I have searched google, jboss forums, quartz support doco and can't find anything. It seems a bit poor to me that Quartz doesn't work with a "final" release of Jboss, as surely a scheduler is a common and required feature of a fully-fledged application server?!

Any suggestions or examples I could follow to get it working?


UPDATE August 28th 2011:

Could someone please help me with this issue? I'm having stability issues and numerous bugs with JBoss 6.0, and contemplating switching to GlassFish 3.1 if Jboss continues to be a challenging endevour. Is it just me or is Jboss just full of bugs and issues?!


The NoClassDefFoundError could be related to a missing dependency. Is the quartz jar-file available in your jboss? Maybe this documentation helps: https://docs.jboss.org/author/display/AS7/How+do+I+migrate+my+application+from+AS5+or+AS6+to+AS7#HowdoImigratemyapplicationfromAS5orAS6toAS7-HowtoResolveClassNotFoundExceptionsandNoCLassDefFoundErrors

Here's my workaround for using quartz in JBoss 7:

Unfortunately AS7 Final doesn't support the @Schedule annotation (see JBoss issue AS7-1158)

So I packed the quartz jar via maven dependencies with my EAR file.

Then I use this startup bean to add the jobs and start the scheduler as described in the quartz examples: http://quartz-scheduler.org/docs/examples/index.html

@Singleton
@Startup
public class StartupBean
{

    @PostConstruct
    private void scheduleJobs()
    {
         // Exception Handling omitted
         final Scheduler sched = new StdSchedulerFactory().getScheduler();
         sched.scheduleJob( createJob(), createTrigger());
         sched.start();
    }

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜