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 help
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>hspLog4j.properties</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 "webapps".
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 [hspLog4j.properties]. java.io.FileNotFoundException: hspLog4j.properties (No such file or directory) at java.io.FileInputStream.open(Native Method)
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.
Jake
..... 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]