Announcement Announcement Module

JavaConfig forum decommissioned in favor of Core Container

As described at

key features of the Spring JavaConfig project have been migrated into the core Spring Framework as of version 3.0.

Please see the Spring 3.0 documentation on @Configuration and @Bean support:

For any questions related to @Configuration classes and @Bean methods in Spring 3.0, please post in the dedicated 'Core Container' forum at
See more
See less
Recursion during bean creation Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Recursion during bean creation

    It will take a bit of work to produce a standalone test for this, so I would like to describe it here first.

    JC is in the process of creating a bean and goes recursive. Here's the synopsis:

    - Way down the stack, "AbstractBeanFactory.getBean(String, Class)#line_168" is executing
    - "CglibConfigurationEnhancer.BeanMethodInterceptor. doIntercept#line_306" is inside the "if(factoryContainsBean(beanName))" if-block
    - "beanFactory.getBean(beanName)" is invoked, since JC sees that the bean creation is in progress
    - Now we go to "DefaultJavaConfigBeanFactory extends AbstractBeanFactory.getBean(String)#line 164"
    - which ultimately leads back to the first method listed above

    Because of some poor legacy code that I'm trying to work thru, I have lots of code that does not inject beans, but rather pulls them from a BeanFactory. In this case, a ClassPathXmlApplicationContext is created (which contains the JC context that I have just recently added) but only the result of "ClassPathXmlApplicationContext.getBeanFactory ()" is saved from which the application extracts its beans. Since this is very non-typical, it could well be an edge case for JC.

  • #2
    BTW, I can get around this recursion by changing bean creation from:

    - beanFactory.getBean(name, type)


    - TypeSafeBeanFactoryUtils.getBean((ListableBeanFact ory) beanFactory, type, name);


    • #3

      Certainly sounds like it may be an issue. I won't have much time to attempt to reproduce it myself this week (SpringOne Americas has got me plenty busy!). So, if you can put together a test case that reproduces the issue, please do so and attach it to a new JIRA issue. If you can get it that far, I should be able to carve some time out to give it a look in pretty short order.


      • #4
        I'll try to do that. But I have already made lots of simplifications and no longer hit the problem, so its not gonna be high on my priority list either.

        Have fun at SpringOne -- I'm gonna miss it this year.