0
votes

I'm trying to set up a couple webapps on tomcat but none of the properties files are getting picked up

2014-02-19 15:47:02,106 - WARN  org.springframework.core.io.support.PropertiesLoaderSupport - Could not load properties from class
 path resource [indexing.properties]: class path resource [indexing.properties] cannot be opened because it does not exist
2014-02-19 15:47:02,110 - WARN  org.springframework.core.io.support.PropertiesLoaderSupport - Could not load properties from class
 path resource [user-service.properties]: class path resource [user-service.properties] cannot be opened because it does not exist
2014-02-19 15:47:05,169 - WARN  com.cubeia.backoffice.users.Configuration - No user-service.properties configuration file found. U
sing default.

The /WEB-INF/classes/service.xml file has the following definition:

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>classpath:default-indexing.properties</value>
            <value>classpath:indexing.properties</value>
        </list>
    </property>
    <property name="ignoreResourceNotFound" value="true" />
</bean>

I've tried copying the .property files everywhere i could think of. tomcat/conf, tomcat/lib, tomcat/conf/Catalina, tomcat/conf/catalina/localhost, webapps//WEB-INF/, webapps//WEB-INF/classes/, then also in the same directory with the actual .class files, temp directory, you name it. Just won't pick it up.

Later edit: I have also tried values like /WEB-INF/classes, WEB-INF/, tomcat/conf, tomcat/lib, classpath*:... all possible combinations basically.

2
Just try by removing classpath: in value tagNaren
Just try by removing classpath: in value tag and keep your properties file in a folder where spring configuration xml existsNaren

2 Answers

1
votes

You should put your properties file in the src/main/resources directory of your webapp. Maven (I'm assuming you're using maven) will then copy this file into your WEB-INF/classes directory for you, which puts it on your classpath. If you then follow the answer from @arahant everything will be fine.

0
votes

The classpath: points to WEB-INF/classes

If you are using Spring MVC 3, you can use the util:properties annotation. The following is an excerpt from a working configuration.

<util:properties id="emailProperties" location="classpath:../email.properties"/>

Here my email.properties is in the WEB-INF directory and hence the ../ before the file name

The util schema is present at http://www.springframework.org/schema/util/spring-util-3.0.xsd