Quartz - ClassCastException

随声附和 提交于 2019-12-12 12:29:06

问题


I am using Jboss5.1.x , EJB3.0 I am trying to configure Quartz. I get this exception when I try to do lookup:

       InitialContext ctx = new InitialContext();
        StdScheduler scheduler = (StdScheduler) ctx.lookup("Quartz");

this is the exception:

java.lang.ClassCastException: org.quartz.impl.StdScheduler cannot be cast to org.quartz.Scheduler

anyone has any idea?

Thanks.


回答1:


You most likely have two copies of the Quartz JAR in your classpath - JBoss has its own copy, and your application probably has one too, in its lib directory. The two are clashing.

Remove the JAR from your application and try again.




回答2:


It's because you have a Scheduler bound to JNDI, so you should do this:

 Scheduler scheduler = (Scheduler) ctx.lookup("Quartz");

Check that you have configured quartz correctly by following this tutorial.




回答3:


The solution is to set the quartzservice in jboss-service.xml in META-INF.

 <module>
     <service>quartzservice.sar</service>
 </module>

That's it. Service is bound and can be used from within the whole EAR.



来源:https://stackoverflow.com/questions/4873221/quartz-classcastexception

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