users@glassfish.java.net

Re: locating a static file on glassfish?

From: <glassfish_at_javadesktop.org>
Date: Sat, 10 Feb 2007 13:03:21 PST

Frankly, it is a bad programming practice to try to locate the resources in a Java EE environment similar to Java EE environment. For one, it makes your code non-portable.

Secondly, you have to use facilities available as described in Servlet and EJB specs. So, please refer to servletContext.getResource and getClassLoader().getResource() methods.

The reason this fails on GlassFish is GlassFish server is started with the current working
directory to be the domain's config directory. So, the [i]relative path[/i] of the java.io.File is w.r.t. that folder.

Hope this helps.

Regards,
Kedar
[Message sent by forum member 'km105526' (km105526)]

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