What happens if a bean attempts to load the Spring application context in its constructor?

If a bean wants a pointer to the application context it's a part of, it should implement ApplicationContextAware You'll implement a setter and Spring will inject the app context into the bean.

If a bean wants a pointer to the application context it's a part of, it should implement ApplicationContextAware. You'll implement a setter and Spring will inject the app context into the bean. Unless I'm mistaken, your sample code won't actually give that bean a pointer to its app context, it will start up a new app context using the same XML file as before.

This will in turn create a new bean, which will start another app context, etc. €” an infinite loop. Try out your code and see whether this happens.

1 Yes, that's exactly what happens! We encountered this error in our own application and I wanted to share our experience in order to help someone else avoid our mistake. – Derek Mahar May 27 '10 at 18:40 By the way, thank you for explaining how a bean can obtain a reference to the application context in which it exists.

– Derek Mahar May 27 '10 at 18:42.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions