Results 1 to 5 of 5

Thread: ClassPathXmlJobRegistry - restriction on number of defined jobs

  1. #1
    Join Date
    Jul 2009
    Posts
    5

    Default 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. #2
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    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)?

  3. #3
    Join Date
    Jul 2009
    Posts
    5

    Default

    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?

  4. #4
    Join Date
    Jun 2005
    Posts
    4,230

    Default

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

  5. #5
    Join Date
    Jul 2009
    Posts
    5

    Default

    Indeed! That's great thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •