|
From: Colin S. <col...@ex...> - 2004-12-21 22:54:02
|
I've run into this while investigating some forum questions. For 1.1.2, Spring became much more aggressive about instantiating FactoryBeans in order to figure out what to autowire. Whereas the before it would not instantiate FactoryBeans for which a type is not known (getObjectType=null), it now seems to instantiate all such FactoryBeans. I'm not sure Juergen actually intended this change, or it's happening because he fixed some other bugs related to getBeansOfType, which I know happened. This is arguably not a great change. One thing it means is that every factory bean (which doesn't declare the return type at least) even if marked lazy-init, will be instantiated as soon as another bean does an autowire. This is what cause people who were using a parent TransactionProxyFactoryBean template marked only lazy=true (but not abstract) to all of a sudden have this parent bean start being instantiated when they switched from 1.1.1 to 1.1.2... I would personally vote to go back to the old behaviour... While this means that autowiring will not work for lazy-loaded singleton factory beans (that have not be instantiated yet), Spring always worked that way anyway, and it can be documented. Colin Patrick Burleson wrote: >A little more information on this: > >This has something to do with auto-wiring. The bean before the bean >that supposedly causes the circular reference was defined to have >auto-wire by type. Once I removed this definition, the circular >dependency went away. Is it a function of auto-wire to try and figure >out the type of every other bean to find dependencies? > >If so, that would probably explain it. As the target bean of a >transaction proxy is dependent on the bean that was defined as >auto-wire. But another transaction proxy target we have is dependent >on the other transaction proxy bean. I know that's really confusing, >but I think it's a common case when one service depends on another. I >guess that's one of the inherent dangers of auto-wiring. I just wonder >why it didn't fail in 1.1.1? > >Thanks, >Patrick > > >On Tue, 21 Dec 2004 11:30:18 -0500, Patrick Burleson ><pbu...@gm...> wrote: > > >>I upgraded our app to use Spring 1.1.3 yesterday and started getting a >>FactoryBeanCircularReferenceException during startup. This error does >>not occur with Spring 1.1.1, haven't tried 1.1.2 just yet. >> >>As far as I can tell, I don't see any circular dependencies in our >>config. It's almost as if the factory forgot to go back and mark one >>of our FactoryBeans as being complete before moving on to the next >>Factory bean. I know that sounds impossible, and it probably is, but I >>at least wanted to get this out there. >> >>I'm going to try and figure out exactly why it thinks there's a >>circular dependency, but it might take some time. >> >>Thanks, >>Patrick >> >> |