如何在Jboss AS 7.0中启用Quartz调度?

发布于 2024-11-25 08:20:06 字数 2024 浏览 2 评论 0原文

Quartz 似乎没有包含在 Jboss AS 7.0 Final(完整版)的默认安装中。当尝试加载消息驱动 Bean (MDB)“FareMonitorBean”时,我的 EAR 部署似乎失败。该MDB 是quartz 调度执行的内容。

错误消息:

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”类文件摘要:

@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 support doco,但找不到任何内容。对我来说,Quartz 不能与 Jboss 的“最终”版本一起工作似乎有点糟糕,因为调度程序肯定是成熟的应用程序服务器的常见且必需的功能?!

我可以遵循任何建议或示例来使其正常工作吗?


2011 年 8 月 28 日更新:

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

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

明媚如初 2024-12-02 08:20:06

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

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

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

因此我通过 EAR 文件的 Maven 依赖项打包了quartz jar。

然后,我使用此启动 bean 添加作业并启动调度程序,如quartz 示例中所述:
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();
    }

}

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

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文