tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <>
Subject Re: Tomcat can't find log4j properties file in war file
Date Wed, 21 Jan 2004 05:03:53 GMT
At 10:04 PM 1/20/2004 -0500, you wrote:
>I have a web app served by Tomcat on a Unix system which I have been running
>out the development environment.  I am trying to deploy it as a jar file.
>When the log4j logging system starts up it says it cannot find the
>properties file in the war file.
>Do I have to specify the properties file location differently?
>More detailed information is below.
>Any suggestions will be greatly appreciated; I thank you in advance for your
>Jim Cant
>At startup, Tomcat loads a servlet to initialize the log4j logging system;
>the name of an initialization file is given in the servlet element in the
>web.xml file:
>          <param-value></param-value>
>The log file is located in the directory 'docBase' in server.xml, specified
>with an absolute path:
>            <Context path="/HSP" docBase="/home/jcant/HSP/WebApp" .....
>This works fine and logging gets initialized.
>However, when I jar up the development into HSP.war and point Tomcat at it,
>the properties file is not found.
>I change server.xml so docBase="HSP.war" and also set 'appbase' to point to
>When Tomcat is restarted, the web app runs fine out of the war file but the
>logging never gets initialized.  The log file has the error message
>                   log4j:ERROR Could not read configuration file
>          (No
>such file or directory)
>                                  at

You are attempting to use File IO on an archive.  This won't work.  In J2EE 
applications, the only place you have guaranteed file system access is in 
the server provided temp directory (provided by a system variable of which 
the name eludes me at the moment).  Use a URL or a normal InputStream to 
load the file.  You can do this via the classloader or via 
context.getResource() and context.getResourceAsStream() methods on the 
ServletContext.  This will make it so you can read the file no matter how 
it is packaged.


>                                  .....
>The properties file is in the root of the war file which is the
>corresponding place to the 'WebApp' directory when running from the
>development environment.
>When I look in $TOMCAT_HOME/work/Standalone/localhost/HSP, I see the WEB-INF
>directory and subdirectories has been deployed but no other files in the war
>file are there.
>To unsubscribe, e-mail:
>For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message