XML : ClassPathXmlApplicationContext - BeanDefinitionStoreException: IOException parsing XML document

I have some unit tests that load an application context from an XML file:

  @BeforeClass  public static void setUp() throws Exception {      ApplicationContext context = new ClassPathXmlApplicationContext("test-application-context.xml");    }    

This throws an exception:

  org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [test-application-context.xml]; nested exception is java.io.FileNotFoundException: class path resource [test-application-context.xml] cannot be opened because it does not exist      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344)      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:216)      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187)      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:251)      at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)      at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)      at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)      at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:542)      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:454)      at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)      at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)    

My unit test class is in the folder:

myproj/myproj-configuration-dal/src/test/java/com/mypatterns/api/data/impl/LogTest.java

The resource file is in:

myproj/myproj-configuration-dal/src/test/resources/test-application-context.xml

I tried moving the xml file around and, also the entire resouce folder, to the following locations: the src folder, the folder where LogTest is, to the main folder (where the non-test sources are) and so on.

Where exactly is this supposed to be? Where is ClassPathXmlApplicationContext looking for the resources?

Thanks, Serban

No comments:

Post a Comment