Error Stack Trace:
SEVERE: StandardWrapper.Throwable org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/dispatcher-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/dispatcher-servlet.xml]
dispatcher-servlet.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:beans="http://springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/task/spring-task.xsd"> <mvc:annotation-driven/> <context:component-scan base-package="com.exam.www" /> <bean id="mongo" class="org.springframework.data.mongodb.core.MongoFactoryBean"> <property name="host" value="localhost" /> </bean> <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> <constructor-arg name="mongo" ref="mongo" /> <constructor-arg name="databaseName" value="Results" /> </bean> <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" /> <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp" p:suffix=".jsp" /> </beans>
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> </beans>
web.xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>WEB-INF/dispatcher-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <context-param> <param-name>contextConfigLocation</param-name> <param-value>WEB-INF/dispatcher-servlet.xml</param-value> </context-param> <welcome-file-list> <welcome-file>/search.jsp</welcome-file> </welcome-file-list> </web-app>
I tried several solutions on the Internet 1) Granting read and write permissions to all files - Does not work 2) Adding init-param - does not work 3) Explicitly providing the dispatch service path as / WebContent / WEB -INF / dispatcher-servlet.xml - not working.
I get this error when starting a project on Apache tomcat v7.0 server
I am struck by this problem for the last 4 days. Please help me.
The following is the solution that worked.
There is no dispatcher-servlet.xml in your war. 1) There is no webapp folder in the project. When you create a project using maven, remember. You can follow the steps given here http://blog.manishchhabra.com/2013/04/spring-data-mongodb-example-with-spring-mvc-3-2/ You would create a project using some strange maven archetype . Try the above link and it works.
I do not find this solution to others where on the Internet. :)
java spring spring-mvc web
user3705478
source share