|
From: <jue...@we...> - 2003-12-15 23:43:08
|
Alef, =20 > Suppose there's two app contexts, A and B. In A there's bean 1 = depending on bean 2 in B. In B, there's bean 3, depending on bean 4 in A. This is circular, however, I still want to somehow be able to do this. Basically the BeanFactory stops processing bean definitions if it can't find a bean reference that might be located in a sibbling context. I tend to state that the bean definition creation should postponed until all sibbling-contexts are resolved and maybe then try it again? Any suggestions (or just 'no not possible' will do as well :) This should be possible already. In case of multiple context definition = files, all the bean definitions from all files get loaded first - *then* = context initialization and bean pre-instantiation begins. The only thing = that doesn't work, because it arguably can't work, is two FactoryBeans = referencing each other. Can you give some details on what doesn't work = in your scenario? =20 Juergen =20 |
|
From: Alef A. <al...@jt...> - 2003-12-15 23:49:00
|
> > Suppose there's two app contexts, A and B. In A there's bean 1 > > depending > on bean 2 in B. In B, there's bean 3, depending on bean 4 in > A. This is circular, however, I still want to somehow be able > to do this. Basically the BeanFactory stops processing bean > definitions if it can't find a bean reference that might be > located in a sibbling context. I tend to state that the bean > definition creation should postponed until all > sibbling-contexts are resolved and maybe then try it again? > Any suggestions (or just 'no not possible' will do as well :) > > This should be possible already. In case of multiple context > definition files, all the bean definitions from all files get > loaded first - *then* context initialization and bean > pre-instantiation begins. The only thing that doesn't work, > because it arguably can't work, is two FactoryBeans > referencing each other. Can you give some details on what > doesn't work in your scenario? I'll ask joost if I can't more details... He's probably got a couple of example context files lying around... Alef |
|
From: Joost v. de W. \(JTeam\) <jo...@jt...> - 2003-12-16 09:38:09
|
QWggb2ssIHNvIHRoZSBhZnRlclByb3BlcnRpZXNTZXQoKSBpcyBjYWxsZWQgKmFmdGVyKiBhbGwg dGhlIGJlYW5zIGFyZSBsb2FkZWQNCmFuZCB0aGUgc2V0dGVycyBhcmUgY2FsbGVkLCBhbmQgdGhl IHNldEFwcGxpY2F0aW9uQ29udGV4dCgpIGhhcyAgYmVlbiBjYWxsZWQNCihpbiBjYXNlIG15IGJl YW4gaXMgQXBwbGljYXRpb25Db250ZXh0QXdhcmUpI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
|
Hi, setApplicationContext() of an ApplicationContextAware bean is called behind of afterPropertiesSet. So it is not possible to load the referenced bean from within afterPropertiesSet. See AbstractBeanFactory line 518 - 520 Best regards Andy > Ah ok, so the afterPropertiesSet() is called *after* all the beans are > loaded and the setters are called, and the setApplicationContext() has > been called (in case my bean is ApplicationContextAware) so I can load the > referenced bean in the afterPropertiesSet() and do my initialization there? > > This will fix my issue i guess, thanx > > Joost > ----- Original Message ----- > From: Alef Arendsen > To: spr...@li... > Cc: Jo...@jt... > Sent: Tuesday, December 16, 2003 12:48 AM > Subject: RE: [Springframework-developer] Hibernate session and > ApplicationContext > > > > Suppose there's two app contexts, A and B. In A there's bean 1 > > > depending > > > > on bean 2 in B. In B, there's bean 3, depending on bean 4 in > > A. This is circular, however, I still want to somehow be able > > to do this. Basically the BeanFactory stops processing bean > > definitions if it can't find a bean reference that might be > > located in a sibbling context. I tend to state that the bean > > definition creation should postponed until all > > sibbling-contexts are resolved and maybe then try it again? > > Any suggestions (or just 'no not possible' will do as well :) > > > > This should be possible already. In case of multiple context > > definition files, all the bean definitions from all files get > > loaded first - *then* context initialization and bean > > pre-instantiation begins. The only thing that doesn't work, > > because it arguably can't work, is two FactoryBeans > > referencing each other. Can you give some details on what > > doesn't work in your scenario? > > I'll ask joost if I can't more details... He's probably got a couple of > example context files lying around... > > Alef -- |
|
From: Alef A. <al...@jt...> - 2003-12-16 11:22:26
|
Ok, the story continues. Juergen, I've added a test to the context.support package, ClasspathXmlApplicationContextTests. There are trhee contexts. B and C have to Logic beans in them. In A, there are two Assembler beans, that both assemble a Service bean (also defined in A) and a Logic bean (assemblerOne collaborates with logicOne, assemblerTwo collaborates with logicTwo). Both Assembler beans are wrapped by a TxProxyFactory (resulting in wrappedAssemblerOne and wrappedAssemblerTwo). These are also defined in A. Then - and that's the issue - logicOne depends on wrappedAssemblerTwo, logicTwo depends on wrappedAssemblerOne. This all goes well - until I let Assembler implement _any_ interface. Right now, I've commented out the implementation in Assembler of TestIF. Just uncomment it, run the test, and it'll fail. As it is located in the CVS, it'll succeed! It seems like the transactionmanager proxy does not implement all interface or something a like. Exception: Can't resolve reference to bean 'logicOne' while setting property 'logic' on bean 'assemblerOne'; nested exception is: org.springframework.beans.FatalBeanException: Can't resolve reference to bean 'wrappedAssemblerTwo' while setting property 'assembler' on bean 'logicOne'; nested exception is: org.springframework.beans.FatalBeanException: Can't resolve reference to bean 'assemblerTwo' while setting property 'target' on bean 'wrappedAssemblerTwo'; nested exception is: org.springframework.beans.FatalBeanException: Can't resolve reference to bean 'logicTwo' while setting property 'logic' on bean 'assemblerTwo'; nested exception is: PropertyVetoExceptionsException: 1 errors:-- ErrorCodedPropertyVetoException: message=[Failed to convert property value of type [$Proxy0] to required type [org.springframework.context.support.Assembler] for property named 'assembler'; nested exception is: java.lang.IllegalArgumentException: argument type mismatch]; errorCode=[typeMismatch] Hope this provides more info on the issue? Alef |
|
From: Rod J. <rod...@in...> - 2003-12-16 11:51:26
|
Alef, I've fixed it--that is, your configuration, not Spring :-) The problem is that you expect the proxy to be of type Assembler, which is a class, not an interface, hence dynamic proxies can't work. Setting proxyTargetClass to be true in the two transactionFactoryProxies solves the problem. The reason it worked if it didn't implement the interface is that TransactionFactoryProxy bean realized that with no interfaces, it had to use CGLIB to proxy the class. I've checked in the changes. Regards, Rod ----- Original Message ----- From: "Alef Arendsen" <al...@jt...> To: <spr...@li...> Cc: <Jo...@jt...> Sent: Tuesday, December 16, 2003 11:21 AM Subject: RE: [Springframework-developer] Hibernate session and ApplicationContext > Ok, the story continues. > > Juergen, I've added a test to the context.support package, > ClasspathXmlApplicationContextTests. > > There are trhee contexts. B and C have to Logic beans in them. In A, > there are two Assembler beans, that both assemble a Service bean (also > defined in A) and a Logic bean (assemblerOne collaborates with logicOne, > assemblerTwo collaborates with logicTwo). Both Assembler beans are > wrapped by a TxProxyFactory (resulting in wrappedAssemblerOne and > wrappedAssemblerTwo). These are also defined in A. > > Then - and that's the issue - logicOne depends on wrappedAssemblerTwo, > logicTwo depends on wrappedAssemblerOne. This all goes well - until I > let Assembler implement _any_ interface. Right now, I've commented out > the implementation in Assembler of TestIF. Just uncomment it, run the > test, and it'll fail. As it is located in the CVS, it'll succeed! It > seems like the transactionmanager proxy does not implement all interface > or something a like. > > Exception: > > Can't resolve reference to bean 'logicOne' while setting property > 'logic' on bean 'assemblerOne'; nested exception is: > org.springframework.beans.FatalBeanException: Can't resolve > reference to bean 'wrappedAssemblerTwo' while setting property > 'assembler' on bean 'logicOne'; nested exception is: > org.springframework.beans.FatalBeanException: Can't resolve > reference to bean 'assemblerTwo' while setting property 'target' on bean > 'wrappedAssemblerTwo'; nested exception is: > org.springframework.beans.FatalBeanException: Can't resolve > reference to bean 'logicTwo' while setting property 'logic' on bean > 'assemblerTwo'; nested exception is: > PropertyVetoExceptionsException: 1 errors:-- > ErrorCodedPropertyVetoException: message=[Failed to convert property > value of type [$Proxy0] to required type > [org.springframework.context.support.Assembler] for property named > 'assembler'; nested exception is: > java.lang.IllegalArgumentException: argument type mismatch]; > errorCode=[typeMismatch] > > Hope this provides more info on the issue? > > Alef > > > > ------------------------------------------------------- > This SF.net email is sponsored by: IBM Linux Tutorials. > Become an expert in LINUX or just sharpen your skills. Sign up for IBM's > Free Linux Tutorials. Learn everything from the bash shell to sys admin. > Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > |