0

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?

5
  • Check if the file it's been copied to your WEB-INF/classes on tomcat. Commented Sep 1, 2016 at 12:08
  • @RicardoVila doesn't look like it's been copied there Commented Sep 1, 2016 at 12:10
  • 1
    When running the application in a tomcat the path under src/main/java/applicationContext.xml is for sure not on the classpath. Please check what the classpath is and what is on it. Commented Sep 1, 2016 at 12:10
  • 1
    non java files should reside in src/main/resource else they will be ignored. Commented Sep 1, 2016 at 12:11
  • @M.Deinum wow that did it thanks Commented Sep 1, 2016 at 12:13

2 Answers 2

1

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> 
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.