如何在 Jboss AS 7.0 中启用 Quartz 调度? [英] How to enable Quartz scheduling in Jboss AS 7.0?

查看:28
本文介绍了如何在 Jboss AS 7.0 中启用 Quartz 调度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Quartz 似乎没有包含在 Jboss AS 7.0 Final(完整版)的默认安装中.尝试加载消息驱动 Bean (MDB)FareMonitorBean"时,EAR 的部署似乎失败.该 MDB 是石英计划执行的内容.

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.

错误信息:

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.myprojectEJB.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

MDBFareMonitorBean"类文件摘要:

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 {
        ....
    }
}

基于 JBoss 文档,我的猜测是需要在standalone/configuration/standalone.xml 中为Quartz 配置扩展"和子系统",但是我不确定如何执行此操作.我已经搜索了 google、jboss 论坛、quartz 支持 doco,但找不到任何东西.对我来说,Quartz 不适用于 Jboss 的最终"版本似乎有点糟糕,因为调度程序肯定是成熟的应用程序服务器的常见和必需功能?!

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?

2011 年 8 月 28 日更新:

UPDATE August 28th 2011:

有人可以帮我解决这个问题吗?我在使用 JBoss 6.0 时遇到了稳定性问题和许多错误,如果 Jboss 仍然是一项具有挑战性的工作,我正在考虑切换到 GlassFish 3.1.是我一个人还是 Jboss 满是 bug 和问题?!

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?!

推荐答案

NoClassDefFoundError 可能与缺少的依赖项有关.您的 jboss 中是否有石英 jar 文件?也许这个文档有帮助:https://docs.jboss.org/author/display/AS7/How+do+I+migrate+my+application+from+AS5+or+AS6+to+AS7#HowdoImigratemyapplicationfromAS5orAS6toAS7-HowtoResolveClassNotFoundExceptionsandNoCLassDefFoundErrors

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

这是我在 JBoss 7 中使用石英的解决方法:

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

不幸的是,AS7 Final 不支持 @Schedule 注释(请参阅 JBoss 问题 AS7-1158)

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

所以我用我的 EAR 文件通过 maven 依赖打包了石英罐.

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

然后我使用这个启动 bean 添加作业并启动调度程序,如石英示例中所述:http://quartz-scheduler.org/docs/examples/index.html

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

}

这篇关于如何在 Jboss AS 7.0 中启用 Quartz 调度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆