I have a web application that runs in Tomcat. I configured my web.xml with:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
I also have some Java classes (not-servlets) that require beans managed by Spring. I would inject them but I am working with another technology that is loading them for me (coming from Flex).
Anyways here is the deal. I have a class, "SpringUtil" that provides static methods for regular Java objects (i.e. not servlets) to access beans. It loads the context as such:
private static ApplicationContext ctx;
static {
final String[] contexts = {"../applicationContext.xml"};
ctx = new ClassPathXmlApplicationContext(contexts);
}
This works fine in production, however, when I run my unit tests they are failing because apparently it can't find the "applicationContext.xml" during testing. How should I fix this? Should my unit test setup the classpath (seems strange to do).


Reply With Quote