JBoss and Quartz

时光毁灭记忆、已成空白 提交于 2019-12-13 05:27:43

问题


I'm trying to see if Quartz can solve a problem for me. But I can't get it to work. Right now I'm stuck at the following error (relevant part)

    Caused by: org.quartz.SchedulerConfigException: Unable to instantiate class load helper class: org.quartz.simpl.CascadingClassLoadHelper cannot be cast to org.quartz.spi.ClassLoadHelper [See nested exception: java.lang.ClassCastException: org.quartz.simpl.CascadingClassLoadHelper cannot be cast to org.quartz.spi.ClassLoadHelper]
    at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:706)
    at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1484)
    at org.jboss.seam.async.QuartzDispatcher.initScheduler(QuartzDispatcher.java:69)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
    at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
    ... 73 more
Caused by: java.lang.ClassCastException: org.quartz.simpl.CascadingClassLoadHelper cannot be cast to org.quartz.spi.ClassLoadHelper
    at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:703)

I have googled and it seems to be a question that is asked a lot but I don't find any answers. I have the quartz-jars in both my webapp and ear.

Is there anything in my configuration that can cause this problem?

JBoss 5.1 Quartz JBoss 2.1.6


回答1:


This is a class loading issue. JBoss already has the org.quartz.spi.ClassLoadHelper.class in its class path since JBoss uses it for internal timers for different tasks. The JBoss provided quartz.jar is located in /jboss-as/common/lib/quartz.jar . So you are providing another quartz.jar with your application which is causing conflict with the existing quartz classes that is provided with JBoss.

To solve this issue you have two options:

  • Option 1. Remove the quartz jars from your ear and war. This is the better and easier option in my opinion unless for some reason you need a different version of quartz for your application than the one JBoss provides.

  • Option 2. Create a META-INF\jboss-classloading.xml file and isolate your ear (and may be your WAR WEB-INF\jboss-classloading.xml if there is a need for the EAR classes to not see WAR classes). This blog is one of the good ones at explaining the jboss5 or jboss6 class loading and this tutorial based blog is also a good resource.



来源:https://stackoverflow.com/questions/14455460/jboss-and-quartz

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!