Wes
Wes

Reputation: 1291

Spring - problems loading applicationContext.xml

When trying to run project on Tomcat I get:

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist

web.xml:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
</context-param>

My applicationContext.xml file is located under src/main/java/applicationContext.xml.

src/main/java is configured as a source folder in the build path of my Eclipse project, so I'm not understanding why Tomcat is not finding applicationContext.xml?

Upvotes: 0

Views: 3045

Answers (2)

Harshal Khatri
Harshal Khatri

Reputation: 51

You should give correct path of the context file, as given below <context-param> <param-name>contextConfigLocation</param-name> <param-value>WEB-INF/classes/applicationContext.xml</param-value> </context-param>

As BeanDefinitionStoreException is thrown when a BeanFactory encounters an invalid bean definition: e.g. in case of incomplete or contradictory bean metadata.

Reference : http://docs.spring.io/autorepo/docs/spring-framework/3.2.17.RELEASE/javadoc-api/org/springframework/beans/factory/BeanDefinitionStoreException.html

Upvotes: 0

Jekin Kalariya
Jekin Kalariya

Reputation: 3507

try to put it under WEB-INF directory and do like below

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/applicationContext.xml
    </param-value>
</context-param>

Upvotes: 1

Related Questions