java - parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; -


i getting few errors in console post below. using eclipse , cleaned project, refreshed target, cleaned tomcat server chasing or of nature not issue.

console error:

severe: context initialization failed org.springframework.beans.factory.beandefinitionstoreexception: ioexception parsing xml document servletcontext resource [/web-inf/applicationcontext.xml]; nested exception java.io.filenotfoundexception: not open servletcontext resource [/web-inf/applicationcontext.xml]     @ org.springframework.beans.factory.xml.xmlbeandefinitionreader.loadbeandefinitions(xmlbeandefinitionreader.java:344)     @ org.springframework.beans.factory.xml.xmlbeandefinitionreader.loadbeandefinitions(xmlbeandefinitionreader.java:304)     @ org.springframework.beans.factory.support.abstractbeandefinitionreader.loadbeandefinitions(abstractbeandefinitionreader.java:181)     @ org.springframework.beans.factory.support.abstractbeandefinitionreader.loadbeandefinitions(abstractbeandefinitionreader.java:217)     @ org.springframework.beans.factory.support.abstractbeandefinitionreader.loadbeandefinitions(abstractbeandefinitionreader.java:188)     @ org.springframework.web.context.support.xmlwebapplicationcontext.loadbeandefinitions(xmlwebapplicationcontext.java:125)     @ org.springframework.web.context.support.xmlwebapplicationcontext.loadbeandefinitions(xmlwebapplicationcontext.java:94)     @ org.springframework.context.support.abstractrefreshableapplicationcontext.refreshbeanfactory(abstractrefreshableapplicationcontext.java:129)     @ org.springframework.context.support.abstractapplicationcontext.obtainfreshbeanfactory(abstractapplicationcontext.java:537)     @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:452)     @ org.springframework.web.context.contextloader.configureandrefreshwebapplicationcontext(contextloader.java:403)     @ org.springframework.web.context.contextloader.initwebapplicationcontext(contextloader.java:306)     @ org.springframework.web.context.contextloaderlistener.contextinitialized(contextloaderlistener.java:106)     @ org.apache.catalina.core.standardcontext.listenerstart(standardcontext.java:4772)     @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5196)     @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:150)     @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1409)     @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1399)     @ java.util.concurrent.futuretask.run(futuretask.java:266)     @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142)     @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617)     @ java.lang.thread.run(thread.java:745) caused by: java.io.filenotfoundexception: not open servletcontext resource [/web-inf/applicationcontext.xml]     @ org.springframework.web.context.support.servletcontextresource.getinputstream(servletcontextresource.java:141)     @ org.springframework.beans.factory.xml.xmlbeandefinitionreader.loadbeandefinitions(xmlbeandefinitionreader.java:330)     ... 21 more  apr 14, 2015 7:57:43 pm org.apache.catalina.core.standardcontext listenerstart severe: exception sending context initialized event listener instance of class org.springframework.web.context.contextloaderlistener org.springframework.beans.factory.beandefinitionstoreexception: ioexception parsing xml document servletcontext resource [/web-inf/applicationcontext.xml]; nested exception java.io.filenotfoundexception: not open servletcontext resource [/web-inf/applicationcontext.xml]     @ org.springframework.beans.factory.xml.xmlbeandefinitionreader.loadbeandefinitions(xmlbeandefinitionreader.java:344)     @ org.springframework.beans.factory.xml.xmlbeandefinitionreader.loadbeandefinitions(xmlbeandefinitionreader.java:304)     @ org.springframework.beans.factory.support.abstractbeandefinitionreader.loadbeandefinitions(abstractbeandefinitionreader.java:181)     @ org.springframework.beans.factory.support.abstractbeandefinitionreader.loadbeandefinitions(abstractbeandefinitionreader.java:217)     @ org.springframework.beans.factory.support.abstractbeandefinitionreader.loadbeandefinitions(abstractbeandefinitionreader.java:188)     @ org.springframework.web.context.support.xmlwebapplicationcontext.loadbeandefinitions(xmlwebapplicationcontext.java:125)     @ org.springframework.web.context.support.xmlwebapplicationcontext.loadbeandefinitions(xmlwebapplicationcontext.java:94)     @ org.springframework.context.support.abstractrefreshableapplicationcontext.refreshbeanfactory(abstractrefreshableapplicationcontext.java:129)     @ org.springframework.context.support.abstractapplicationcontext.obtainfreshbeanfactory(abstractapplicationcontext.java:537)     @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:452)     @ org.springframework.web.context.contextloader.configureandrefreshwebapplicationcontext(contextloader.java:403)     @ org.springframework.web.context.contextloader.initwebapplicationcontext(contextloader.java:306)     @ org.springframework.web.context.contextloaderlistener.contextinitialized(contextloaderlistener.java:106)     @ org.apache.catalina.core.standardcontext.listenerstart(standardcontext.java:4772)     @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5196)     @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:150)     @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1409)     @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1399)     @ java.util.concurrent.futuretask.run(futuretask.java:266)     @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142)     @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617)     @ java.lang.thread.run(thread.java:745) caused by: java.io.filenotfoundexception: not open servletcontext resource [/web-inf/applicationcontext.xml]     @ org.springframework.web.context.support.servletcontextresource.getinputstream(servletcontextresource.java:141)     @ org.springframework.beans.factory.xml.xmlbeandefinitionreader.loadbeandefinitions(xmlbeandefinitionreader.java:330)     ... 21 more  apr 14, 2015 7:57:43 pm org.apache.catalina.core.standardcontext startinternal severe: error listenerstart apr 14, 2015 7:57:43 pm org.apache.catalina.core.standardcontext startinternal severe: context [/offers] startup failed due previous errors apr 14, 2015 7:57:43 pm org.apache.catalina.core.applicationcontext log info: closing spring root webapplicationcontext apr 14, 2015 7:57:43 pm org.springframework.web.context.support.xmlwebapplicationcontext doclose info: closing root webapplicationcontext: startup date [tue apr 14 19:57:43 cest 2015]; root of context hierarchy apr 14, 2015 7:57:43 pm org.springframework.web.context.support.xmlwebapplicationcontext doclose warning: exception thrown applicationlistener handling contextclosedevent java.lang.illegalstateexception: applicationeventmulticaster not initialized - call 'refresh' before multicasting events via context: root webapplicationcontext: startup date [tue apr 14 19:57:43 cest 2015]; root of context hierarchy     @ org.springframework.context.support.abstractapplicationcontext.getapplicationeventmulticaster(abstractapplicationcontext.java:344)     @ org.springframework.context.support.abstractapplicationcontext.publishevent(abstractapplicationcontext.java:331)     @ org.springframework.context.support.abstractapplicationcontext.doclose(abstractapplicationcontext.java:869)     @ org.springframework.context.support.abstractapplicationcontext.close(abstractapplicationcontext.java:836)     @ org.springframework.web.context.contextloader.closewebapplicationcontext(contextloader.java:579)     @ org.springframework.web.context.contextloaderlistener.contextdestroyed(contextloaderlistener.java:115)     @ org.apache.catalina.core.standardcontext.listenerstop(standardcontext.java:4813)     @ org.apache.catalina.core.standardcontext.stopinternal(standardcontext.java:5413)     @ org.apache.catalina.util.lifecyclebase.stop(lifecyclebase.java:232)     @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:160)     @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1409)     @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1399)     @ java.util.concurrent.futuretask.run(futuretask.java:266)     @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142)     @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617)     @ java.lang.thread.run(thread.java:745)  apr 14, 2015 7:57:43 pm org.springframework.web.context.support.xmlwebapplicationcontext doclose warning: exception thrown lifecycleprocessor on context close java.lang.illegalstateexception: lifecycleprocessor not initialized - call 'refresh' before invoking lifecycle methods via context: root webapplicationcontext: startup date [tue apr 14 19:57:43 cest 2015]; root of context hierarchy     @ org.springframework.context.support.abstractapplicationcontext.getlifecycleprocessor(abstractapplicationcontext.java:357)     @ org.springframework.context.support.abstractapplicationcontext.doclose(abstractapplicationcontext.java:877)     @ org.springframework.context.support.abstractapplicationcontext.close(abstractapplicationcontext.java:836)     @ org.springframework.web.context.contextloader.closewebapplicationcontext(contextloader.java:579)     @ org.springframework.web.context.contextloaderlistener.contextdestroyed(contextloaderlistener.java:115)     @ org.apache.catalina.core.standardcontext.listenerstop(standardcontext.java:4813)     @ org.apache.catalina.core.standardcontext.stopinternal(standardcontext.java:5413)     @ org.apache.catalina.util.lifecyclebase.stop(lifecyclebase.java:232)     @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:160)     @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1409)     @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1399)     @ java.util.concurrent.futuretask.run(futuretask.java:266)     @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142)     @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617)     @ java.lang.thread.run(thread.java:745)  apr 14, 2015 7:57:43 pm org.apache.catalina.core.standardcontext listenerstop severe: exception sending context destroyed event listener instance of class org.springframework.web.context.contextloaderlistener java.lang.illegalstateexception: beanfactory not initialized or closed - call 'refresh' before accessing beans via applicationcontext     @ org.springframework.context.support.abstractrefreshableapplicationcontext.getbeanfactory(abstractrefreshableapplicationcontext.java:170)     @ org.springframework.context.support.abstractapplicationcontext.destroybeans(abstractapplicationcontext.java:908)     @ org.springframework.context.support.abstractapplicationcontext.doclose(abstractapplicationcontext.java:884)     @ org.springframework.context.support.abstractapplicationcontext.close(abstractapplicationcontext.java:836)     @ org.springframework.web.context.contextloader.closewebapplicationcontext(contextloader.java:579)     @ org.springframework.web.context.contextloaderlistener.contextdestroyed(contextloaderlistener.java:115)     @ org.apache.catalina.core.standardcontext.listenerstop(standardcontext.java:4813)     @ org.apache.catalina.core.standardcontext.stopinternal(standardcontext.java:5413)     @ org.apache.catalina.util.lifecyclebase.stop(lifecyclebase.java:232)     @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:160)     @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1409)     @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1399)     @ java.util.concurrent.futuretask.run(futuretask.java:266)     @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142)     @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617)     @ java.lang.thread.run(thread.java:745)  apr 14, 2015 7:57:43 pm org.apache.coyote.abstractprotocol start info: starting protocolhandler ["http-nio-8080"] apr 14, 2015 7:57:43 pm org.apache.coyote.abstractprotocol start info: starting protocolhandler ["ajp-nio-8009"] apr 14, 2015 7:57:43 pm org.apache.catalina.startup.catalina start info: server startup in 2475 ms 

web.xml

<?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"     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>spring_project</display-name>     <welcome-file-list>         <welcome-file>index.html</welcome-file>         <welcome-file>index.htm</welcome-file>         <welcome-file>index.jsp</welcome-file>         <welcome-file>default.html</welcome-file>         <welcome-file>default.htm</welcome-file>         <welcome-file>default.jsp</welcome-file>     </welcome-file-list>      <servlet>         <description>offers</description>         <display-name>offers</display-name>         <servlet-name>offers</servlet-name>         <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>         <load-on-startup>1</load-on-startup>     </servlet>      <servlet-mapping>         <servlet-name>offers</servlet-name>         <url-pattern>/</url-pattern>     </servlet-mapping>      <description>database</description>     <resource-ref>         <description>db connection</description>         <res-ref-name>jdbc/spring_tutorial</res-ref-name>         <res-type>javax.sql.datasource</res-type>         <res-auth>container</res-auth>     </resource-ref>      <listener>         <listener-class>org.springframework.web.context.contextloaderlistener</listener-class>     </listener>      <context-param>         <param-name>contextconfiglocation</param-name>         <param-value>             classpath:com/learnspring/config/daocontext.xml             classpath:com/learnspring/config/offersservice.xml         </param-value>     </context-param>   </web-app> 

daocontext.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:jee="http://www.springframework.org/schema/jee"     xmlns:context="http://www.springframework.org/schema/context"     xsi:schemalocation="http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.1.xsd         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">        <context:annotation-config></context:annotation-config>     <context:component-scan         base-package="com.learnspring.datasource.dao">     </context:component-scan>     <jee:jndi-lookup jndi-name="jdbc/spring_tutorial" id="datasource"         expected-type="javax.sql.datasource">     </jee:jndi-lookup> </beans> 

offersservice

<?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"     xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">       <context:annotation-config></context:annotation-config>     <context:component-scan base-package="com.learnspring.service"></context:component-scan> </beans> 

offerscontroller

package com.learnspring.controller;  import java.util.list;  import org.springframework.beans.factory.annotation.autowired; import org.springframework.stereotype.controller; import org.springframework.ui.model; import org.springframework.web.bind.annotation.requestmapping;  import com.learnspring.datasource.dao.offer; import com.learnspring.service.offersservice;  @controller public class offerscontroller {      private offersservice offersservice;      @autowired     public void setoffersservice(offersservice offersservice) {         this.offersservice = offersservice;     }      @requestmapping("/")     public string gethome(model model) {          list<offer> offers = offersservice.getcurrent();          model.addattribute("offers", offers);         return "home";     }  } 

offersservice.java

package com.learnspring.service;  import java.util.list;  import org.springframework.beans.factory.annotation.autowired; import org.springframework.stereotype.service;  import com.learnspring.datasource.dao.offer; import com.learnspring.datasource.dao.offerdao;  @service("offersservice") public class offersservice {      private offerdao offerdao;      @autowired     public void setofferdao(offerdao offerdao) {         this.offerdao = offerdao;     }        public list<offer> getcurrent() {          return offerdao.getoffers();     }  } 

home.jsp

<%@ page language="java" contenttype="text/html; charset=utf-8"     pageencoding="utf-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>  <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>insert title here</title> </head> <body>     hello world jsp...      <c:foreach var="row" items="${offers}">     id ${row.id}<br />     name ${row.name}<br />     name ${row.email}<br />     name ${row.text}<br />     </c:foreach>  </body> </html> 

if want load files using contextloaderlistener, remove dispatcher servlet , should work fine or use below method load final.

<servlet> <servlet-name>offers</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <init-param>     <param-name>contextconfiglocation</param-name>     <param-value> classpath:com/learnspring/config/daocontext.xml         classpath:com/learnspring/config/offersservice.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> 


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -