Announcement Announcement Module
Collapse
No announcement yet.
ClassPathXmlJobRegistry - restriction on number of defined jobs Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ClassPathXmlJobRegistry - restriction on number of defined jobs

    I'm wondering why the ClassPathXmlJobRegistry refuses to load an application context when it defines multiples beans that are instances of Job.

    What's the rationale behind this restriction?

    Thanks,
    Philippe

  • #2
    As far as I know there is no such restriction. Are you using CommandLineJobRunner (up to 2.0.1 it was fussy about the number of jobs in its context)?

    Comment


    • #3
      This is from the ClassPathXmlJobRegistry#afterPropertiesSet method:

      Code:
      String[] names = context.getBeanNamesForType(Job.class);
      
      if (names.length > 1) {
        throw new DuplicateJobException("More than one Job found for resource: [" + resource + "]");
      }
      where "resource" is the application context XML file. This is the test that I'm wondering about. Why would it refuse an application ctx with more than one Job bean?

      Comment


      • #4
        I don't know. That's why I removed that test in 2.0.2.

        Comment


        • #5
          Indeed! That's great thanks.

          Comment

          Working...
          X