• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get the full path of the properties file loaded by my application?

 
Jeevan Sunkersett
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My app is a Web application, employs Spring, Apache CXF, ... and is deployed on Tomcat-7.
In META-INF\context.xml I specify an additional class-path element


At initialization time, it loads up a property file, (using PropertyPlaceholderConfigurer)
from within the jar/ war as well as from the file system (if found in the additional class-path)
For this I have used the following



The logs specifically say;
Loading properties file from URL [jar:file:/D:/WMSandbox/tools/apache-tomcat-7.0.40/wtpwebapps/Myserver-web/WEB-INF/lib/Myserver-1.0.0-SNAPSHOT.jar!/myConfig.properties]
Loading properties file from URL [file:/D:/opt/xyz/config/myConfig.properties]

But the path(s) are (is) only getting printed in the log.
At run time, I need the exact file:/ path in a variable - how can I get that?

Using


gave me only the exact paths of the jar's used by my application but not the file:/ path of the property file (loaded from the file system/ outside the .jar)

Any clues, how I can get the full path of the property file (loaded from the file system)

Thank you
g1
 
krishna atok
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeevan,
Configure a bean as below
<bean id="test" class="TestClass">
<property name="propertyLoader" ref="cnsproperties" />
</bean>

With the above you will the propertyplaceholderconfigurer object and play with it using the getter methods or inbuilt methods contianed by this class. Hope you should be able to get the desired output. Let me know the results.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!