Announcement Announcement Module
Collapse
No announcement yet.
3.1.M2 + Quartz 2: Errors on new AdaptableJobFactory changes? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 3.1.M2 + Quartz 2: Errors on new AdaptableJobFactory changes?

    Yes, I know, spring does not collaborate with Quartz 2.0. But, Juergen Hoeller made a change to at least AdaptableJobFactory works with it in Spring 3.1.M2. Thank you, Jürgen! The small Changeset: https://fisheye.springsource.org/cha...mework?cs=4375

    But: That change does not work for me. I'm getting a IncompatibleClassChangeError. The source is here in AdaptableJobFactory on createJobInstance:

    PHP Code:
    protected Object createJobInstance(TriggerFiredBundle bundlethrows Exception {
        return 
    bundle.getJobDetail().getJobClass().newInstance();

    Strange: In Eclipse debugger I can watch the result from newInstance(), which gives me my Object, which is a JobDetail-Class Instance, which implements the Job interface.
    Exception text: Found interface org.quartz.JobDetail, but class was expected.
    Calls which fires job creation:
    PHP Code:
    JobDetail job org.quartz.JobBuilder.newJob(MyJob.class). ... .build();
    scheduler.scheduleJob(jobtrg); 
    Signature of MyJob:
    PHP Code:
    public class MyJob implements Job {...} 
    Versions: Spring 3.1.M2, Quartz 2.0.2 (from Maven), Java 6, OS X
    Last edited by sja; Jul 14th, 2011, 05:39 AM. Reason: 3.2 -> 3.1

  • #2
    Hello

    Post the complete error stack trace to get a clear idea about the case

    If you are totally sure that you are using the same frameworks and specifically the same version release used by Jürgen and you followed his instructions, you perhaps found out a a bug and a JIRA issue would be consider it

    Comment


    • #3
      Ok, I'm very sure, that I use the same Versions, because I got them from Maven, I see the Code and it's the same than in the Changeset.

      Here's my StackTrace:

      PHP Code:
      10:29:35  DEBUG my.project.scheduler.amqp.ConfigMessageHandler Starting dispatcher for Message my.project.scheduler.amqp.messages.ConfigMessage@4d811e2c
      10
      :29:35  TRACE my.project.scheduler.amqp.HostHandler Handling configMessage!
      10:29:35  INFO  my.project.scheduler.amqp.HostHandler Created new Host check for host devl.intranet
      10
      :29:35  ERROR org.quartz.core.ErrorLogger An error occured instantiating job to be executedjob'HostChecks.1-check1'
      org.quartz.SchedulerExceptionProblem instantiating class 'my.project.scheduler.jobs.ReachableCheckJob' -  [See nested exceptionjava.lang.IncompatibleClassChangeErrorFound interface org.quartz.JobDetailbut class was expected]
          
      at org.quartz.core.JobRunShell.initialize(JobRunShell.java:141)
          
      at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:381)
      Caused byjava.lang.IncompatibleClassChangeErrorFound interface org.quartz.JobDetailbut class was expected
          at org
      .springframework.scheduling.quartz.AdaptableJobFactory.createJobInstance(AdaptableJobFactory.java:68)
          
      at org.springframework.scheduling.quartz.AdaptableJobFactory.newJob(AdaptableJobFactory.java:51)
          
      at org.springframework.scheduling.quartz.AdaptableJobFactory.newJob(AdaptableJobFactory.java:43)
          
      at org.quartz.core.JobRunShell.initialize(JobRunShell.java:134)
          ... 
      1 more
      10
      :29:35  INFO  org.springframework.scheduling.quartz.LocalDataSourceJobStore All triggers of Job HostCheckTrigger.HLMonTrigger-1-check1 set to ERROR state
      HostHandler:
      PHP Code:
      void handleHostAction(ConfigMessage configMessage) {
              
      Assert.isTrue(configMessage.getTarget().equals(TargetObject.HOST));
              
      logger.trace("Handling configMessage!");

              
      GenericConfig config configMessage.getConfigObject();
              
      Map<StringObjectconfigMap config.getConfigMap();
              final 
      String checkName = (String) configMap.get("name");
              final 
      String hostname = (String) configMap.get("hostname");
              switch (
      configMessage.getAction()) {
              case 
      UPDATE:
                  
      logger.debug("UPDATE " configMap);
                  break;
              case 
      CREATE:
                  try {
                      
      int interval Integer.parseInt((String) configMap.get("interval"));

                      
      JobDetail job newJob(ReachableCheckJob.class).withIdentity(checkName"HostChecks").storeDurably()
                              .
      requestRecovery().usingJobData("hostname"hostname).build();

                      
      Trigger trg newTrigger().withIdentity("MonTrigger-" checkName"HostCheckTrigger").startNow()
                              .
      forJob(job).withSchedule(simpleSchedule().withIntervalInSeconds(interval).repeatForever())
                              .
      build();

                      
      scheduler.scheduleJob(jobtrg);
                      
      logger.info("Created new Host check for hot " hostname);

                  } catch (
      Exception e) {
                      
      logger.error("Could not create or update!");
                      
      logger.debug("Host Data: " configMape);
                  }
                  break;
              case 
      DELETE:
                  try {
                      
      logger.debug("DELETE " configMap);
                  } catch (
      Exception e) {
                      
      logger.error("Could not delete!");
                      
      logger.debug("Calendar name to delete: " checkNamee);
                  }
                  break;
              default:
                  throw new 
      IllegalArgumentException("Could not handle not yet implemented Action:"
                          
      configMessage.getAction());
              } 
      Legend:
      ConfigMessageHandler: Dispatches ConfigMessage Beans received by AMQP to Special Handlers, e.g. HostHandler
      Last edited by sja; Jul 18th, 2011, 04:49 AM. Reason: updated code

      Comment


      • #4
        Juergen Hoeller answered in Jira:
        Good catch - the fix in 3.1 M2 was incomplete. I've fixed this for 3.1 RC1, as part of a general Quartz 2.0 update: Except for JobDetailBean and the TriggerBeans, the entire Spring Quartz support is compatible with Quartz 2.0 now (making quite heavy use of reflection internally), while at the same time remaining compatible with Quartz 1.5+.
        Juergen
        The Changeset is here:
        https://fisheye.springsource.org/cha...obFactory.java
        Last edited by sja; Jul 20th, 2011, 03:58 AM. Reason: added changeset url

        Comment

        Working...
        X