java - Spring doesn't file properties files -


i'm having troubles accessing properties files spring. here arborescence :

web-inf    - application-context.xml    - properties       -applicationperperties.xml       -csvheader.properties 

here import in application-context.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:context="http://www.springframework.org/schema/context"     xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:util="http://www.springframework.org/schema/util"     xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd         http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"     profile="dev, test, prod">      <import resource="properties/applicationproperties.xml" /> </beans> 

here import in applicationproperties.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:context="http://www.springframework.org/schema/context"     xmlns:util="http://www.springframework.org/schema/util"     xsi:schemalocation="     http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans-3.2.xsd     http://www.springframework.org/schema/util      http://www.springframework.org/schema/util/spring-util-3.0.xsd     http://www.springframework.org/schema/context   http://www.springframework.org/schema/context/spring-context-3.0.xsd">      <util:properties id="csvdictionnaryproperties"  location="csvheader.properties" /> </beans> 

what don't understand fact spring find applicationproperties.xml doesn't find csvheader.properties. tried moving file root folder, adding classpath prefix , so, can't manage make work. filenotfoundexception.

here stacktrace :

11:24:54,710 error [contextloader] context initialization failed org.springframework.beans.factory.beancreationexception: error creating bean name 'csvdictionnaryproperties': invocation of init method failed; nested exception java.io.filenotfoundexception: not open servletcontext resource [/csvheader.properties]     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:1482)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:521)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:458)     @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:295)     @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:223)     @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:292)     @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:194)     @ org.springframework.beans.factory.support.defaultlistablebeanfactory.preinstantiatesingletons(defaultlistablebeanfactory.java:608)     @ org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:932)     @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:479)     @ org.springframework.web.context.contextloader.configureandrefreshwebapplicationcontext(contextloader.java:389)     @ org.springframework.web.context.contextloader.initwebapplicationcontext(contextloader.java:294)     @ org.springframework.web.context.contextloaderlistener.contextinitialized(contextloaderlistener.java:112)     @ org.apache.catalina.core.standardcontext.listenerstart(standardcontext.java:4887)     @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5381)     @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:150)     @ org.apache.catalina.core.containerbase.addchildinternal(containerbase.java:901)     @ org.apache.catalina.core.containerbase.addchild(containerbase.java:877)     @ org.apache.catalina.core.standardhost.addchild(standardhost.java:633)     @ org.apache.catalina.startup.hostconfig.deploywar(hostconfig.java:976)     @ org.apache.catalina.startup.hostconfig$deploywar.run(hostconfig.java:1653)     @ java.util.concurrent.executors$runnableadapter.call(executors.java:471)     @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:334)     @ java.util.concurrent.futuretask.run(futuretask.java:166)     @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145)     @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615)     @ java.lang.thread.run(thread.java:724) caused by: java.io.filenotfoundexception: not open servletcontext resource [/csvheader.properties]     @ org.springframework.web.context.support.servletcontextresource.getinputstream(servletcontextresource.java:140)     @ org.springframework.core.io.support.encodedresource.getinputstream(encodedresource.java:143)     @ org.springframework.core.io.support.propertiesloaderutils.fillproperties(propertiesloaderutils.java:98)     @ org.springframework.core.io.support.propertiesloadersupport.loadproperties(propertiesloadersupport.java:175)     @ org.springframework.core.io.support.propertiesloadersupport.mergeproperties(propertiesloadersupport.java:156)     @ org.springframework.beans.factory.config.propertiesfactorybean.createinstance(propertiesfactorybean.java:113)     @ org.springframework.beans.factory.config.propertiesfactorybean.createproperties(propertiesfactorybean.java:98)     @ org.springframework.beans.factory.config.propertiesfactorybean.afterpropertiesset(propertiesfactorybean.java:69)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.invokeinitmethods(abstractautowirecapablebeanfactory.java:1541)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebe 

as can see, seems searches csvheader.properties in / directory, can't understand why. i'm new spring, i'm don't understand all. ideas why doesn't work ?

the .properties file needs in classpath. put in web-inf/classes of project , refer classpath:csvheader.properties. spring find then.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -