Skip to main content

[v3.1] setting java.io.tmpdir?

1 reply [Last post]
kawazu
Offline
Joined: 2005-08-03
Points: 0

Folks,

experiencing a strange behaviour in 3.1, I wanted to check back with everybody to see whether what I am doing might be my fault or a different kind of problem: Generally, I do have a piece of code that fetches files off some backend repository and keeps them stored in a temporary location for further processing. For the sake of cutting configuration effort, I decided to want to use java.io.tmpdir for all these purposes. So, here's how things are:

  • Initially, java.io.tmpdir seems to resolve to glassfishv3/glassfish/domains/domain1/config/. Which, in my opinion, is a pretty dumb default as I do not at all want to have temporary files living next to my domain configuration. Anyway, files end up there, and the application seems to "see" files there, too.
  • Using "-Djava.io.tmpdir=/tmp/app/", I see the peculiar behaviour that, in general, files indeed go there instead of the domain1/config folder. However, the servlet storing them there always still does return the glassfish/domains/domain1/config/<filename> path doing "getAbsolutePath" on the File instance after storing.

Huh? Am I completely missing something, or is something wrong here? There _is_ a way making Glassfish v3 use a java.io.tmpdir outside of its domain folder, ain't there? TIA for any hints on that, all the best,

Kristian

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bnevins
Offline
Joined: 2005-03-28
Points: 0

GlassFish does not and probably CAN NOT change the temp dir. The JDK
itself sets it by (presumably) asking the OS. I just added this line:

message += "\njava.io.tmpdir=" + System.getProperty("java.io.tmpdir");

to UptimeCommand.java. I rebuilt and ran "asadmin uptime" and I see this:

d:\gf\v3\core\kernel>asadmin uptime
Up 14 secs*
java.io.tmpdir=c:\tmp\
*-- which is precisely what I expected to see.
============

What YOU are seeing for the temp dir is actually your current working
directory. GlassFish has an iron-clad guarantee. If you start with
asadmin then your current working directory will be the server's config dir.

Try running a simple one line java program that prints out
java.io.tmpdir. If you see the current directory then you probably need
to set a tempdir environmental variable in your environment.

On 7/11/2011 5:38 AM, forums@java.net wrote:
> Folks,
>
> experiencing a strange behaviour in 3.1, I wanted to check back with
> everybody to see whether what I am doing might be my fault or a different
> kind of problem: Generally, I do have a piece of code that fetches
> files off
> some backend repository and keeps them stored in a temporary location for
> further processing. For the sake of cutting configuration effort, I
> decided
> to want to use java.io.tmpdir for all these purposes. So, here's how
> things
> are:
>
> * Initially, java.io.tmpdir seems to resolve to
> glassfishv3/glassfish/domains/domain1/config/. Which, in my
> opinion, is a
> pretty dumb default as I do not at all want to have temporary files
> living
> next to my domain configuration. Anyway, files end up there, and the
> application seems to "see" files there, too.
> * Using "-Djava.io.tmpdir=/tmp/app/", I see the peculiar behaviour
> that, in
> general, files indeed go there instead of the domain1/config folder.
> However, the servlet storing them there always still does return the
> glassfish/domains/domain1/config/ path doing
> "getAbsolutePath"
> on the File instance after storing.
>
> Huh? Am I completely missing something, or is something wrong here? There
> _is_ a way making Glassfish v3 use a java.io.tmpdir outside of its domain
> folder, ain't there? TIA for any hints on that, all the best,
>
> Kristian
>
>
> --
>
> [Message sent by forum member 'kawazu']
>
> View Post: http://forums.java.net/node/820791
>
>

--
Oracle
Byron Nevins | Principal MTS
Phone: +1 6503958992

Green Oracle Oracle is committed to
developing practices and products that help protect the environment