Announcement Announcement Module
Collapse
No announcement yet.
Error - First Spring Configuration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error - First Spring Configuration

    Hey guys, I'm having a hard time trying to set up my environment to work with Spring ... any help I'll be glad.

    web.xml

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" 
    	xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
    	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
    	id="WebApp_ID" version="3.0">
    	
       <display-name>First Application</display-name>
      
       <welcome-file-list>
         <welcome-file>Login.jsp</welcome-file>
         <welcome-file>login.jsp</welcome-file>
       </welcome-file-list>
     
       <servlet>
           <servlet-name>applicationContext</servlet-name>
           <servlet-class>
               org.springframework.web.servlet.DispatcherServlet
           </servlet-class>
           <load-on-startup>1</load-on-startup>
       </servlet>
       
    	<listener> 
           <listener-class> 
               org.springframework.web.context.ContextLoaderListener 
           </listener-class> 
       </listener>
    </web-app>
    applicationContext.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?> 
    <beans xmlns="http://www.springframework.org/schema/beans"
       			xmlns:context="http://www.springframework.org/schema/context"
       			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
       				http://www.springframework.org/schema/context 
       				http://www.springframework.org/schema/context/spring-context-3.0.xsd">
        
        <context:annotation-config />
        <!-- All controllers are included using @Controller annotation -->
        <context:component-scan base-package="armagedom.controller" />   
           
    	<!-- RESOLVE A VIEW NAME -->
    	<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        	<property name="prefix" value="/WEB-INF/views/" />
        	<property name="suffix" value=".jsp" />
      	</bean>
    </beans>
    My paths are the default: web.xml and applicationContext are located into WebContent/WEB-INF

    Here is the log of the errors that I've been facing
    HTML Code:
    Context initialization failed
    org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext-servlet.xml]
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:343)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:216)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187)
    	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
    	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
    	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
    	at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:551)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:465)
    	at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:658)
    	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:606)
    	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:672)
    	at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:525)
    	at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:466)
    	at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    	at javax.servlet.GenericServlet.init(GenericServlet.java:160)
    	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
    	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
    	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
    	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176)
    	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460)
    	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    	at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    	at java.util.concurrent.FutureTask.run(Unknown Source)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    	at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext-servlet.xml]
    	at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:141)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:329)
    	... 29 more
    Jul 19, 2013 4:05:30 PM org.apache.catalina.core.ApplicationContext log
    SEVERE: StandardWrapper.Throwable
    org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext-servlet.xml]
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:343)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:216)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187)
    	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
    	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
    	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
    	at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:551)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:465)
    	at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:658)
    	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:606)
    	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:672)
    	at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:525)
    	at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:466)
    	at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    	at javax.servlet.GenericServlet.init(GenericServlet.java:160)
    	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
    	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
    	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
    	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176)
    	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460)
    	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    	at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    	at java.util.concurrent.FutureTask.run(Unknown Source)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    	at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext-servlet.xml]
    	at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:141)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:329)
    	... 29 more
    I tryied to change the name of the applicationContext.xml to applicationContext-servlet.xml but didn't work out too ....

    I'm blocked in this, could someone help me ?

    Thanks in advanced !

  • #2
    It can't find the file. Trying mucking around with the paths in a context config location in web.xml e.g.:

    Code:
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>
                            /WebContent/WEB-INF/applicationContext.xml
    		</param-value>
    	</context-param>

    Comment

    Working...
    X