When i use class-path attribute in spring XML file as below,
<bean class="com.fritolay.suppliernet.common.lastresorthandler.impl.SingletonPropertiesRepository">
<property name="propertiesFile" value="classpath:ecr/sample.properties" />
</bean>
In this case where does the server looks for properties file in application?
My question is that i have two modules[1.Web Project 2.Java Project]. I am defining this XML file in web project and placing properties files under java project src folder.But when i deploy my application i am getting following error:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'propertiesFile' threw exception; nested exception is java.io.FileNotFoundException: class path resource [ecr/sample.properties] cannot be resolved to absolute file path because it does not reside in the file system: zip:C:/Oracle/Middleware/user_projects/domains/sample/servers/AdminServer/tmp/_WL_user/_appsdir_supplier-net_ear/6e86rt/sample-service.jar!/ecr/sample.properties
Your Java engine is looking for your file at this location (read at your error):
As you can see, the
!mark implies it is looking for your file inside a temporary JAR file (for sure, an IDE artifact).It seems that your IDE (or the tool you have chosen for deployment) is not including your properties files inside the JAR, and thus the error.
It may be because of:
compilation target directory (usualy
/classes)propertiesresources into the Jar, avoiding them.In both cases, to fix it you must check your building and deployment configuration, depending on which IDE or tools you are using.