Announcement Announcement Module
Collapse
No announcement yet.
IdGeneratorConfigurer causes 'Context initialization failed' Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Hello.

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

    Artem Bilan

    Comment


    • #3
      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

      Comment


      • #4
        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

        Comment


        • #5
          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

          Comment


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

            Thanks

            Comment


            • #7
              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

              Comment


              • #8
                Hi Artem, I read and commented it too

                Comment


                • #9
                  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?

                  Comment


                  • #10


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

                    Comment


                    • #11
                      Yes, Dennis, it does.
                      I understand getBeansOfType code.

                      I want to say you're going to catch the same problem with any other invokes of this method not only on IdGeneratorConfigurer.
                      We can simply fix it for you as allowEagerInit = false, but where are the guarantees that evething will be OK in many features of other frameworks...

                      Comment


                      • #12
                        You are right, I know, it is a problem that we have corrupt beans in our project, from time to time... But I can't avoid it in this big project...

                        My thinking was: In the other cases if I use a framework-method and run into this problem, I could/must handle this problem. But in this case here, I doesn't invoke anything... The framework does and I can't even startup my application.

                        I don't know, and yes, perhaps it is a chance to clean up the project and to enforce more attention by my collegues

                        Comment


                        • #13
                          Ultimately, if you have invalid configuration, it's going to result in an error at some point. It just happens that the IdGeneratorConfigurer is the first thing trying to initialize beans as defined within your context.

                          Comment


                          • #14
                            I know and try to convince my team.

                            Comment

                            Working...
                            X