This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

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.

Comment

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.