Get the CATALINA_BASE property from inside a Java Web Service

java, jax-ws, log4j, tomcat7

Solution

try `System.getProperty("catalina.base");`

Problem

Dear fellow Developers, I am working on improving my Java Web Services, and I am trying to use a more delicate way of getting the directory path of properties files in a Java Web Service. In order to make my Java Web Application easier to be deployed on an Apache Tomcat Server, I add the following line to the web.xml file: ``` <env-entry> <env-entry-name>loggerPropertyFile</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>/Some/Long/Directory/File/Path/Which/May/Change/conf/LoggerInfo.properties</env-entry-value> </env-entry> ``` As the above xml code depicts, I have placed a Properties file somewhere in the local Filesystem, and I want my Web Service to initialize its logger class, based on that configuration. As you can realize this path changes every time I deploy my web service to another server. Thus, I figured out that I may be able to use the $CATALINA_BASE property, in order to make the environment entry path smaller. How can I retrieve the CATALINA_BASE value from inside my Java Web Service's Code (how is done on Linux and how is done on Windows)?? Thank you.

Original source