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

查看:133
本文介绍了如何在Jboss AS 7.0中启用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

MDB"FareMonitorBean"类文件的摘要:

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配置扩展"和子系统",但是我不确定如何执行此操作.我搜索了谷歌,jboss论坛,石英支持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充满了错误和问题?!

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#HowdoIASratemyapplicationfromAS5orAS6toAS7-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天全站免登陆