Announcement Announcement Module
Collapse
No announcement yet.
Could not open ServletContext resource [/WEB-INF/dispatch-servlet.xml] Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Could not open ServletContext resource [/WEB-INF/dispatch-servlet.xml]

    I am having a problem trying to compile and deploy a simple Spring web application. It seems that once deployed the server cannot open dispatch-servlet.xml. Anybody have an idea what is going on here? Does it look like a spring problem or something else? I have listed the xeb-xml dispatch-servlet.xml, and glassfish server messages below.

    web-xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" 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">
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/applicationContext.xml</param-value>
        </context-param>
        <context-param>
            <param-name>log4jConfigLocation</param-name>
            <param-value>/WEB-INF/log4j.properties</param-value>
        </context-param>
        <context-param>
            <param-name>log4jRefreshInterval</param-name>
            <param-value>1000</param-value>
        </context-param>
        <listener>
            <listener-class>
                org.springframework.web.util.Log4jConfigListener
            </listener-class>
        </listener>
        <listener>
            <listener-class>
                org.springframework.web.context.ContextLoaderListener
            </listener-class>
        </listener>
        <servlet>
            <servlet-name>dispatch</servlet-name>
            <servlet-class>
                org.springframework.web.servlet.DispatcherServlet
            </servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>dispatch</servlet-name>
            <url-pattern>/send/*</url-pattern>
        </servlet-mapping>
        <session-config>
            <session-timeout>
                30
            </session-timeout>
        </session-config>
        <welcome-file-list>
            <welcome-file>unwelcome.jsp</welcome-file>
            </welcome-file-list>
        </web-app>
    dispatch-servlet.xml
    Code:
    <?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:p="http://www.springframework.org/schema/p"
           xmlns:aop="http://www.springframework.org/schema/aop"
           xmlns:tx="http://www.springframework.org/schema/tx"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
        
        <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
        
        <!--
        Most controllers will use the ControllerClassNameHandlerMapping above, but
        for the index controller we are using ParameterizableViewController, so we must
        define an explicit mapping for it.
        -->
        <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="mappings">
                <props>
                    <prop key="/doit">dispatchController</prop>
                </props>
            </property>
        </bean>
        
        <bean id="viewResolver"
       class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="prefix">
                <value>/WEB-INF/views/</value>
            </property>
            <property name="suffix">
                <value>.jsp</value>
            </property>
        </bean>
    
        <bean id="dispatchController"
       class="com.memestorm.web.DispatchController">
           <property name="methodNameResolver" ref="paramResolver"></property>
        </bean>
        
    </beans>
    Code:
    2009-05-25 15:39:24,808 ERROR (org.springframework.web.servlet.DispatcherServlet:244) - Context initialization failed
    org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/dispatch-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/dispatch-servlet.xml]
            at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:320)
            at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:290)
            at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:142)
            at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:158)
            at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
            at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
            at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:97)
            at 
    ADM5603:Event listener error [ContainerBase.addChild: start: LifecycleException:  java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/dispatch-servlet.xml]]
    ADM1075:Error on listening event:[ContainerBase.addChild: start: LifecycleException:  java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/dispatch-servlet.xml]]

  • #2
    Well judging from the stacktrace the file is not in the desired location. Make sure it is in the WEB-INF directory not somewhere else. Make sure it is in your war file...

    Comment

    Working...
    X