How to host JSP project on yahoo server?

How do I resolve BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/dispatcher-servlet.xml] in Java Spring MVC web project?

  • 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 http://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="Index of /schema/beans" xmlns:xsi="Page on w3.org" xmlns:context="Index of /schema/context" xmlns:p="Page on springframework.org" xmlns:mvc="Index of /schema/mvc" xmlns:beans="Index of /beans" xsi:schemaLocation="Page on springframework.org Page on springframework.org Page on springframework.org Page on springframework.org"> <mvc:annotation-driven/> <context:component-scan base-package="com.exam.www" /> <!-- Factory bean that creates the Mongo instance --> <bean id="mongo" class="org.springframework.data.mongodb.core.MongoFactoryBean"> <property name="host" value="localhost" /> </bean> <!-- MongoTemplate for connecting and quering the documents in the database --> <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> <constructor-arg name="mongo" ref="mongo" /> <constructor-arg name="databaseName" value="Results" /> </bean> <!-- Use this post processor to translate any MongoExceptions thrown in @Repository annotated classes --> <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" /> <!-- <bean class="org.springframework.web.servlet.view.tiles2.TilesViewResolver"/> <bean class= "org.springframework.web.servlet.view.tiles2.TilesConfigurer"> --> <!-- <property name="definitions"> <list> <value>/WEB-INF/views/views.xml</value> </list> </property> </bean> --> </beans> applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="Index of /schema/beans" xmlns:xsi="Page on w3.org" xsi:schemaLocation="Index of /schema/beans Page on springframework.org"> <!-- Root Context: defines shared resources visible to all other web components --> <!-- CSRF protection. Here we only include the CsrfFilter instead of all of Spring Security. See Spring Security Reference for more information on Spring Security's CSRF protection --> <!-- <bean id="csrfFilter" class="org.springframework.security.web.csrf.CsrfFilter"> <constructor-arg> <bean class="org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository"/> </constructor-arg> </bean> --> <!-- Provides automatic CSRF token inclusion when using Spring MVC Form tags or Thymeleaf. See Page on localhost:8080 and form.jsp for examples --> <!-- <bean id="requestDataValueProcessor" class="org.springframework.security.web.servlet.support.csrf.CsrfRequestDataValueProcessor"/> --> </beans> web.xml <web-app xmlns="Java EE: XML Schemas for Java EE Deployment Descriptors" xmlns:xsi="Page on w3.org" xsi:schemaLocation="Java EE: XML Schemas for Java EE Deployment Descriptors Page on sun.com" version="2.5"> <!-- <display-name>Spring With MongoDB Web Application</display-name> --> <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 given online like 1) Giving read, write permissions to all files - Doesn't work 2) Adding init-param - doesn't work 3) Explicitly giving path of dispatcherservlet as /WebContent/WEB-INF/dispatcher-servlet.xml - doesn't work. I get this error when I run the project on Apache tomcat server v7.0 I am struck with this problem for past 4 days. I have also asked this in stackoverflow and no positive response. Please help me.

  • Answer:

    In your WAR file, is the dispatcher-servlet.xml in the WEB-INF folder?

Jayesh Lalwani at Quora Visit the source

Was this solution helpful to you?

Other answers

Try unpacking your war file to check if the file is in the WEB-INF folder. It clearly complains that it cannot find it. I would remove all init params as well, the file is on the standard location. You should also always work from something that works towards something new, if your code doesn't work start with something simpler from a tutorial or maven archetype. Maybe something like this: http://jeromejaglale.com/doc/java/spring/hello_world

Martin Stolz

Your configurations looks good. There should be a problem in packaging. Check if you have the file in correct location.

Krishna Srinivasan

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.