logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alan Yost" <Alan.Y...@yambay.com>
Subject RE: Getting the root directory of my ear file from a servlet.
Date Thu, 08 Aug 2002 16:27:31 GMT
Thanks for the quick reply - I had just moved onto this and now I'm trying to work out the
syntax required for it.
If I have a file in the root of mydeploy.ear - what is the correct syntax for when using getResource?
At present I am using       URL myFileURL =  config.getServletContext().getResource("log4j.lcf");
but this returns a null.
I have tried several variations on this but to no avail.  Do you any examples of the above
type of syntax working?
Regards and thanks in advance

	-----Original Message----- 
	From: Shapira, Yoav [mailto:Yoav.Shapira@mpi.com] 
	Sent: Fri 9/08/2002 12:07 AM 
	To: Log4J Users List 
	Subject: RE: Getting the root directory of my ear file from a servlet.

	The servlet spec does not guarantee you will get a real path at all when
	deploying from a war. 
	You should never rely on getRealPath() in that case.  See the JavaDoc
	for getRealPath() for a more
	complete explanation.  There have also been several discussions on this
	matter on the tomcat-user mailing
	list recently.
	Instead, you should use getResource() or getResourceAsStream() in your
	Yoav Shapira
	Millennium ChemInformatics
	-----Original Message-----
	From: Alan Yost [mailto:Alan.Yost@yambay.com]
	Sent: Thursday, August 08, 2002 12:12 PM
	To: Log4J Users List
	Subject: Getting the root directory of my ear file from a servlet.
	Hi all,
	I'm trying to use the init() method of a class that extends HttpServlet
	to read in a properties file when a servlet is first deployed.  I have
	looked at the example on pg 13 of Ceki Gulcu's "Short introduction to
	log4j" related to configuring log4j during initialisation.  The problem
	I seem to be having is that when I specify the following code I don't
	get the expected real path - but one that JBoss "mirrors" in the
	String prefix  =  config.getServletContext().getRealPath("/log4j.lcf");
	Rather than return the get JBoss\..\deploy\MyDeployFile.ear\mypath I get
	something like:
	C:\Documents and Settings\alany\Local
	Ideally what I would like to be able to do is to have a configuration
	file in the root of "MyDeployFile.ear" and reference this but I am not
	sure how to get this address.
	Any ideas would be appreciated.

View raw message