tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject Re: installing with web app mgr, failing on getRealPath("")
Date Tue, 13 Aug 2002 13:21:16 GMT
First, I believe the syntax should be:
getServletContext().getRealPath("/");

Second, the returned null value is to be expected.

keep in mind that getRealPath() returns an absolute file system path to 
your application context.  When you serve the context straight out of a 
.war file, your web application does not actually exist on the file 
system.   This means that there is no place to write to within your 
app.  This is one of the perils of serving your webapp directly from a .war 
file.

The way around this is to provide a parameter at startup that tells your 
logger where to store log files.  I assume you are initializing your logger 
using a servlet that is set to run upon application startup.  If so, check 
for null being returned by getRealPath("j/") and, if so, maybe use the 
user.home system property as a place to store the log file by default or, 
if provided, use the path configured in the web.xml for the startup servlet.


Jake

At 05:12 AM 8/13/2002 +0000, you wrote:
>When i install my app as an exploded war file in webapps it runs fine
>but when I install it using Tomcat Web Application Manager it fails on
>getServletContext().getRealPath("");
>
>What's the deal? I want to set a path to a log file by obtaining the
>app realpath and then subtracting "/webapps/" and substituting
>"/logs/". Is there a better way to do that?
>
>Daniel
>kehoe@fortuity.com
>
>On Tue, 13 Aug 2002 03:25:30 UT, "Daniel Kehoe" <kehoe@fortuity.com>
>said:
> > > Here's how to install a web app using the Tomcat Web Application
> > > Manager.... After trial and error, here's what works for files in a 
> local Windows
> > > file system:
> > > Path: "/crossbar"
> > Config URL: "file:///C:/Projects/Crossbar/dist/crossbar.xml"
> > WAR URL: "file:///C:/Projects/Crossbar/dist/crossbar.war"
> > >
> > > The "Path" is the context name you want for the web app, like
> > > http://localhost:8080/crossbar/.
> > >
> > > The "Config URL" is a path to a file that contains the parameters you
> > > would otherwise add to the server.xml file (or add to the webapps
> > > directory as a file "crossbar.xml" under the new TC4.1 scheme).
> > >
> > > The "WAR URL" is the path to the war file.
> > It COULD begin with "jar:file://" and end with "!/" but it doesn't have
> > to.
>
>--
>To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message