Thursday, August 5, 2010

Spring - Which resources are actually loaded in Spring Context?

Today I got a really weird behavior: some spring context file was loaded into the same context twice. This caused exception, since some beans are expected to be singletons, while I got two instances.

In this post I'm not going to describe what exactly was the problem. But rather how I investigated it.

So in order to see what are the actual files being loaded and what is the source of the definition that caused them to be loaded I put a breakpoint in org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(InputSource, Resource).

That's all. Try it yourself :)

No comments: