I have a couple of applicationContext-xxx-xxx.xml files. I have a master applicationContext.xml file where I import all the other files. Now when I start my application every bean gets initialized. When I run my application, I get a NullPointer as one of the bean that I define in my applicationContext-xxx-1.xml is being referenced in applicationContext-xxx-2.xml. I was under the impression that this should not be a problem as during runtime they all know about each other. Any ideas what might be wrong here that leads to this exception.
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
As was stated you need to give us more details:
1. stack trace
2. The configuration for the bean causing the issue
3. Your web.xml so we can see how you are loading your application contexts files.
That said I assume you have beans with dependencies on other beans in different xml files. Are you using the ref attribute for this? If you are and visibility to that bean was an issue I would be expecting to see a NoSuchBeanDefintionException not a null pointer.
You say that every bean gets initialized. Have you validated this? If not its possible you are loading one context file only and if you have not imported the others they are not getting initialized. Lastly if you have a dependency in one bean on another and you are not using the ref attribute (for example if the bean is dependent on the other from something happening in a static initializer block) then you will need to use the dependsOn attribute to notify Spring explicitly that there is a dependency.
Lastly is this error occur on startup? If not then ignore everything I just stated and first make sure that you are actually using a Spring managed bean. Dependency Injection is only done on Spring managed beans.