tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Miguel Almeida <migueldealme...@gmail.com>
Subject Re: [Tomcat 7] Why can't you use automatic deployment and exploded WAR when docBase is outside appBase?
Date Mon, 06 Aug 2012 20:43:03 GMT
Thanks for the input regarding 2). What's the difference between using
javax.servlet.context.tempdir  vs java.io.tmpdir ?

Also, do you know the answer to 1 - ie, why did the change occur regarding
not exploding when the WAR is outside appBase?


On Mon, Aug 6, 2012 at 9:32 PM, Mark Eggers <its_toasted@yahoo.com> wrote:

> On 8/6/2012 12:40 PM, Caldarale, Charles R wrote:
>
>> From: Miguel Almeida [mailto:migueldealmeida@gmail.**com<migueldealmeida@gmail.com>
>>> ]
>>> Subject: [Tomcat 7] Why can't you use automatic deployment
>>> and exploded WAR when docBase is outside appBase?
>>>
>>
>>  The motivation for this is a simple code ServletContext.getRealPath("/"*
>>> *)
>>> to create a simple temporary inputstream that works in Tomcat6 but
>>> doesn't
>>> in Tomcat7 (because getRealPath("/") will return null).
>>>
>>
>> And, if you check the servlet spec, getRealPath() is *never* guaranteed
>> to work.  Your code should be using either getResourceAsStream() or looking
>> at the javax.servlet.context.tempdir context attribute to find where it can
>> create temporary files.
>>
>>   - Chuck
>>
>
> +1
>
> I just spent the better part of a week ferreting out exactly this mess.
> The original application would read from and write to files inside the web
> application. Even worse, the original application hard-coded the path in a
> set of variables set at web application load time.
>
> This meant that every time the server was changed, the application moved,
> or the application name changed, the war file had to be unpacked, these
> values changed, and then the war file had to be repacked.
>
> Use getResourceAsStream() for things you need to read. Put those items in
> WEB-INF/classes or in a jar in WEB-INF/lib. If you need to write temporary
> files, use java.io.tmpdir, file.separator, and possibly createTempFile().
>
> Tomcat (catalina.sh) sets java.io.tmpdir to $CATALINA_BASE/temp for your
> convenience by default.
>
> . . . just my (somewhat frustrated) 2 cents.
> /mde/
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.**apache.org<users-unsubscribe@tomcat.apache.org>
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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