Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: IdGeneratorConfigurer causes 'Context initialization failed'

  1. #1
    Join Date
    Jan 2012
    Location
    Hannover, Germany
    Posts
    9

    Default IdGeneratorConfigurer causes 'Context initialization failed'

    Hello,

    I am testing to see if spring-integration (Version 2.1.0) could help me with a problem.

    But, as how it is now, IdGeneratorConfigurer causes a 'Context initialization failed' i.e. if any bean class can not be found. We have a big project and this can occur...

    Problem seems to to be the following line in IdGeneratorConfigurer:
    Code:
    boolean contextHasIdGenerator = context.getBeanNamesForType(IdGenerator.class).length > 0;
    if I change it to:
    Code:
    boolean contextHasIdGenerator = context.getBeanNamesForType(IdGenerator.class, false, false).length > 0;
    everything works fine. Is it a bug?

  2. #2
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    644

    Default

    Hello.

    Can you show more info?
    StackTrace, Spring version, environment etc.

    Artem Bilan

  3. #3
    Join Date
    Jan 2012
    Location
    Hannover, Germany
    Posts
    9

    Default

    Versions:
    Spring 3.1
    Spring-integration 2.1.0

    It is a very big project with a many declared beans. It is at all times possible that there are bean definitions of beans that can't be instantiated (no class, error on constructing, ...). We can't avoid that. Parts of our software will not work, yes, but the rest can ignore that.

    But with using Spring integration (IdGeneratorConfigurer) I can not even start the application because it will 'test' all defined beans...

    I hope it is getting more clear what I mean (?)

    --
    Thanks,
    Dennis Hoersch

  4. #4
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    644

    Default

    Ok.
    I may assume the problem is in
    Code:
    context.getBeanNamesForType(IdGenerator.class, false, false)
    on last argument allowEagerInit and it throws CannotLoadBeanClassException.
    Can you play with true/false for this argument?

    If it is that the issue is in Spring Core, but no Spring Integration.

    Cheers,
    Artem

  5. #5
    Join Date
    Jan 2012
    Location
    Hannover, Germany
    Posts
    9

    Default

    The original code in IdGeneratorConfigurer is:
    Code:
    context.getBeanNamesForType(IdGenerator.class)
    which calls
    Code:
    context.getBeanNamesForType(IdGenerator.class, true, true)
    which causes an inspect of all beans.

    I tested also:
    Code:
    context.getBeanNamesForType(IdGenerator.class, true, false)
    this works well...
    So the question is, is it necessary to enable allowEagerInit in IdGeneratorConfigurer?

    --
    Dennis

  6. #6
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    644

    Default

    Can you open an issue in JIRA and we will think about it ...

    Thanks

  7. #7
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    644

    Default

    Dennis, please read my comment in the JIRA: https://jira.springsource.org/browse/INT-2410.
    And try to fix problems with beans in your project.

    Good luck

  8. #8
    Join Date
    Jan 2012
    Location
    Hannover, Germany
    Posts
    9

    Default

    Hi Artem, I read and commented it too

  9. #9
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    644

    Default

    Hi, Dennis!

    Please, let continue to discuss here.

    Can you debug you application's start up and look for what's going on in the DefaultListableBeanFactory#getBeanNamesForType on IdGeneratorConfigurer#onApplicationEvent?
    What causes a CannotLoadBeanClassException?

  10. #10
    Join Date
    Jan 2012
    Location
    Hannover, Germany
    Posts
    9

    Default



    I have no access to my workspace from home, so I will debug it on monday.

    But what I can remember is that if allowEagerInit is true getBeansOfType will rethrow the CannotLoadBeanClassException instead of silently ignore that. getBeansOfType does this for all beans, not only for those of the given type... (but of what should he know that the not loadable class is of some type ;-))

Posting Permissions

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