I have working web-application with applicationContext.xml in WEB-INF/config/applicationContext.xml. Now i need to implement some testing tool as standalone application, that can use the same applicationContext.xml, but have problem with path to config for ClassPathXmlApplicationContext class.
I know that when i copy applicationContext.xml to default package (where .java resides) i can use ClassPathXmlApplicationContext("applicationContext.xml"), but is this necessary ?
import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class AdminTool {
private Logger log = Logger.getLogger(getClass());
/** all below doesn't work - FileNotFoundException) **/
private static final ApplicationContext ac = new ClassPathXmlApplicationContext("/WEB-INF/config/applicationContext.xml");
private static final ApplicationContext ac = new ClassPathXmlApplicationContext("config/applicationContext.xml");
private static final ApplicationContext ac = new ClassPathXmlApplicationContext("../config/applicationContext.xml");
public static void main(String[] args) {
new AdminTool();
}
public AdminTool() {
log.debug(ac);
}
}