Forums Register Login

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

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
Every snowflake is perfect and unique. And every snowflake contains a very tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2382 times.
Similar Threads
Http 404 Error
HTTP 404 Error
ActionForm class
first struts application error
Servlet action is not available
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 11:50:00.