Can any one tell me if it is possible if an application can have two Spring containers ?? if yes [i belive so] , how JVM going to handle this.
also, like to know , when we define ContextLoaderListener into web.xml, how that going to load applicationcontext.xml file.
First question yet. As many ApplicationContext instances that you want. ApplicationContext is just a pojo, so how does any class work if they are instantiated twice. I create two Person objects, how is the JVM going to handle this.
So from the JVM perspective there is nothing special to handle.
Now there is a concept of parent-child application contexts where the child context can see all the beans in the parent context, but not the other way around.
Second question applicationContext.xml in the WEB-INF directory is just the default file location and name that the ContextLoaderListener is looking for. You can always call it something else, put it somewhere else, then you have to include a <context-param> tag in your web.xml to point to it. That is why I like the default file name and location.
The listener gets called right after the Web Container create a ServletContext for the web app. When it gets called it creates an XmlWebApplicationContext and loads in your config file.