users@glassfish.java.net

Access domain path from java

From: <glassfish_at_javadesktop.org>
Date: Sun, 25 Jul 2010 03:54:54 PDT

Hello,

I am trying to write files to the directory of the domain my application is running on (domain1). The writing is done from within a Message Driven Bean. So far I have done this by using absolute file paths. It works but obviously its not an ideal solution, because if I want to run the application on a different Glassfish server those paths will most likely not work anymore.

I tried to not use paths with a leading / which worked on one Glassfish instance, it created those files relative to the domain1 directory. However on a different Glassfish instance this did not work and it tried to create the files somewhere completely different, that's when i switched to absolute file paths.

So I am wondering if it is possible to access configuration variables or something similar from within an EJB so I can find out the path to the active domain root. That way i could dynamically create absolute file paths in my MDB. But maybe there is also a configuration fix that makes GLassfish use all relative file paths relative to the active domain root.

Thanks for your help!
[Message sent by forum member 'kmunteanu']

http://forums.java.net/jive/thread.jspa?messageID=478509