Spring Batch Admin
  1. Spring Batch Admin
  2. BATCHADM-126

Adding Spring TaskScheduler causes proxy for job service which fails for missing method removeInactiveExecutions

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.2.1
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      I am trying to use Spring Scheduler to automate execution of some batch jobs. However, when I add <task:annotation-driven/> to my application context I receive a NoSuchMethodException on removeInactiveExecutions. I believe this is because the task scheduler is trying to create a proxy for the jobservice. However, the execution-context.xml file in spring-batch-admin-manager META-INF/spring/batch/bootstrap/manager has a scheduled job entry that is calling removeInactiveExecutions on the job service, which is not in the interface. If I remove the <task:annotation-driven/> and define my scheduled tasks in xml the issue disappears, but excludes the ability to use annotations to schedule tasks. I think the removeInactiveExecutions method needs to be added to the JobService interface.

        Activity

        Hide
        Dave Syer added a comment -

        That method is really an implementation detail so I don't think it should be part of the interface. It would be easier just to remove the annotation from the SimpleJobService.

        In the meantime, one possible approach would be to use proxy-target-class=true in the proxy generator - that isn't exposed in the task namespace (you should raise a separate SPR-* ticket for that if you want to do that), but you could get it working with bean definitions probably. Or maybe you could set up a child context and split the annotated and non-annotated scheduled tasks between the two? If you want to execute jobs with your scheduler, maybe they belong in the child context along with the jobs anyway. If that doesn't work we can look at why not.

        Show
        Dave Syer added a comment - That method is really an implementation detail so I don't think it should be part of the interface. It would be easier just to remove the annotation from the SimpleJobService. In the meantime, one possible approach would be to use proxy-target-class=true in the proxy generator - that isn't exposed in the task namespace (you should raise a separate SPR-* ticket for that if you want to do that), but you could get it working with bean definitions probably. Or maybe you could set up a child context and split the annotated and non-annotated scheduled tasks between the two? If you want to execute jobs with your scheduler, maybe they belong in the child context along with the jobs anyway. If that doesn't work we can look at why not.
        Hide
        Dan Anderson added a comment -

        Placing the annotation-driven definition in the child xml does seem to have worked around the issue. Thanks for your help!

        Show
        Dan Anderson added a comment - Placing the annotation-driven definition in the child xml does seem to have worked around the issue. Thanks for your help!
        Hide
        Timo Meinen added a comment -

        Putting the annotation-driven definition into the child xml doesn't work with Spring 3.2. Any other solution?

        Show
        Timo Meinen added a comment - Putting the annotation-driven definition into the child xml doesn't work with Spring 3.2. Any other solution?

          People

          • Assignee:
            Dave Syer
            Reporter:
            Dan Anderson
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: