users@glassfish.java.net

Re: migrating from v2.1 to v3 issues

From: Jan Luehe <Jan.Luehe_at_Sun.COM>
Date: Wed, 06 Jan 2010 12:47:51 -0800

On 01/ 6/10 03:16 AM, glassfish_at_javadesktop.org wrote:
> I even tried on Linux Ubuntu over Sun's JDK 1.6u7, also not working, can't read anything with "getResourceAsStream" function.
>

GlassFish v3 has started enforcing the Servlet spec requirement that the
specified resource path start with '/', as per the javadocs of
javax.servlet.ServletContext#getResourceAsStream:

  The path must be specified according
  to the rules given in <code>getResource</code>.
  This method returns <code>null</code> if no resource exists at
  the specified path.

and javax.servlet.ServletContext#getResource:

  Returns a URL to the resource that is mapped to the given path.
  The path must begin with a <tt>/</tt> and is interpreted [...]

Try changing

  getServletContext().getResourceAsStream("WEB-INF/file.properties");

to

  getServletContext().getResourceAsStream("/WEB-INF/file.properties");

Thanks,

Jan

> [Message sent by forum member 'snovak7' (snovak7_at_gmail.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=378995
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>