Announcement Announcement Module
Collapse
No announcement yet.
How to resolve Could not open ServletContext resource Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to resolve Could not open ServletContext resource

    I use webwork and spring and hibernate do a project;
    but when i deploy them.
    Tomcat consoleOut show some message as follows:

    2007-5-11 9:38:18 org.apache.catalina.core.StandardContext listenerStart
    严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListe ner
    org.springframework.beans.factory.BeanDefinitionSt oreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
    Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
    at org.springframework.web.context.support.ServletCon textResource.getInputStream(ServletContextResource .java:99)
    at
    .
    .
    2007-5-11 9:38:18 org.apache.catalina.core.StandardContext start
    严重: Error listenerStart
    2007-5-11 9:38:18 org.apache.catalina.core.StandardContext start
    严重: Context [/book] startup failed due to previous errors
    2007-5-11 9:38:18 org.apache.catalina.core.ApplicationContext log
    信息: Closing Spring root WebApplicationContext

    web.xml as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4"
    xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <filter>
    <filter-name>webwork</filter-name>
    <filter-class>com.opensymphony.webwork.dispatcher.FilterDi spatcher</filter-class>
    </filter>

    <filter-mapping>
    <filter-name>webwork</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>

    <listener>
    <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
    </listener>

    </web-app>

    applicationContext as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

    <beans>


    <bean id="MSSQL" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName">
    <value>com.microsoft.jdbc.sqlserver.SQLServerDrive r</value>
    </property>
    <property name="url">
    <value>
    jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=wwBookstore
    </value>
    </property>
    <property name="username">
    <value>wwork</value>
    </property>
    <property name="password">
    <value>123</value>
    </property>
    </bean>

    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
    <property name="dataSource">
    <ref bean="MSSQL" />
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">
    org.hibernate.dialect.SQLServerDialect
    </prop>
    </props>
    </property>
    <property name="mappingResources">
    <list>
    <value>org/hlonger/wshmbookstore/vo/Orders.hbm.xml</value>
    <value>
    org/hlonger/wshmbookstore/vo/OrderItem.hbm.xml
    </value>
    <value>
    org/hlonger/wshmbookstore/vo/Catalog.hbm.xml
    </value>
    <value>org/hlonger/wshmbookstore/vo/Book.hbm.xml</value>
    <value>org/hlonger/wshmbookstore/vo/User.hbm.xml</value>
    </list>
    </property>
    </bean>

    <bean id="BaseDAO" class="org.hlonger.wshmbookstore.dao.BaseDAO">
    <property name="sessionFactory">
    <ref bean="sessionFactory"/>
    </property>
    </bean>

    <bean id="userDAO" class="org.hlonger.wshmbookstore.dao.impl.UserDAO" parent="BaseDAO">
    </bean>

    <bean id="userService" class="org.hlonger.wshmbookstore.service.impl.User Service">
    <property name="userDAO">
    <ref bean="userDAO"/>
    </property>
    </bean>

    <bean id="userAction" class="org.hlonger.wshmbookstore.action.UserAction ">
    <property name="userService">
    <ref bean="userService"/>
    </property>
    </bean>


    </beans>

    I wish someone can help me resolve this problem.

  • #2
    What is the location of your applicationContext.xml file? It should reside in the /WEB-INF folder. Or you need to specify it's exact location.

    Comment


    • #4
      java.io.FileNotFoundException: Could not open ServletContext resource

      hi,
      i m using spring,hibernate,jsp

      when i m calling the login page then on tomcat console im getting this bug.
      but when i give the relative path of my hibernate.properties file then it will work fine my application work.but still on tomcat console im getting this bug.

      plz help it is urgent...


      java.io.FileNotFoundException: Could not open ServletContext resource [/C:/Tomcat 5.5/webapps/gurdiantoolwebbase/WEB-INF/hibernate.properties]
      at org.springframework.web.context.support.ServletCon textResource.getInputStream(ServletContextResource .java:99)
      at org.springframework.core.io.support.PropertiesLoad erSupport.loadProperties(PropertiesLoaderSupport.j ava:172)
      at org.springframework.core.io.support.PropertiesLoad erSupport.mergeProperties(PropertiesLoaderSupport. java:151)
      at org.springframework.beans.factory.config.PropertyR esourceConfigurer.postProcessBeanFactory(PropertyR esourceConfigurer.java:69)
      at org.springframework.context.support.AbstractApplic ationContext.invokeBeanFactoryPostProcessors(Abstr actApplicationContext.java:380)
      at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:302)
      at org.springframework.web.context.support.AbstractRe freshableWebApplicationContext.refresh(AbstractRef reshableWebApplicationContext.java:134)
      at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:246)
      at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:184)
      at org.springframework.web.context.ContextLoaderServl et.init(ContextLoaderServlet.java:83)
      at javax.servlet.GenericServlet.init(GenericServlet.j ava:212)
      at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:1139)
      at org.apache.catalina.core.StandardWrapper.load(Stan dardWrapper.java:966)
      at org.apache.catalina.core.StandardContext.loadOnSta rtup(StandardContext.java:3956)
      at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4230)
      at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1014)
      at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:736)
      at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1014)
      at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:443)
      at org.apache.catalina.core.StandardService.start(Sta ndardService.java:448)
      at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:700)
      at org.apache.catalina.startup.Catalina.start(Catalin a.java:552)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:295)
      at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:433)
      ERROR-StandardWrapper.Throwable
      org.springframework.beans.factory.BeanInitializati onException: Could not load properties; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/C:/Tomcat 5.5/webapps/gurdiantoolwebbase/WEB-INF/hibernate.properties]
      java.io.FileNotFoundException: Could not open ServletContext resource [/C:/Tomcat 5.5/webapps/gurdiantoolwebbase/WEB-INF/hibernate.properties]
      at org.springframework.web.context.support.ServletCon textResource.getInputStream(ServletContextResource .java:99)
      at org.springframework.core.io.support.PropertiesLoad erSupport.loadProperties(PropertiesLoaderSupport.j ava:172)
      at org.springframework.core.io.support.PropertiesLoad erSupport.mergeProperties(PropertiesLoaderSupport. java:151)
      at org.springframework.beans.factory.config.PropertyR esourceConfigurer.postProcessBeanFactory(PropertyR esourceConfigurer.java:69)
      at org.springframework.context.support.AbstractApplic ationContext.invokeBeanFactoryPostProcessors(Abstr actApplicationContext.java:380)
      at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:302)
      at org.springframework.web.context.support.AbstractRe freshableWebApplicationContext.refresh(AbstractRef reshableWebApplicationContext.java:134)
      at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:246)
      at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:184)
      at org.springframework.web.context.ContextLoaderServl et.init(ContextLoaderServlet.java:83)
      at javax.servlet.GenericServlet.init(GenericServlet.j ava:212)
      at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:1139)
      at org.apache.catalina.core.StandardWrapper.load(Stan dardWrapper.java:966)
      at org.apache.catalina.core.StandardContext.loadOnSta rtup(StandardContext.java:3956)
      at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4230)
      at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1014)
      at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:736)
      at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1014)
      at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:443)
      at org.apache.catalina.core.StandardService.start(Sta ndardService.java:448)
      at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:700)
      at org.apache.catalina.startup.Catalina.start(Catalin a.java:552)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:295)
      at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:433)
      ERROR-Servlet /gurdiantoolwebbase threw load() exception

      Comment

      Working...
      X