ejb@glassfish.java.net

Re: Problem resolving relative path within ear

From: Cheng Fang <Cheng.Fang_at_Sun.COM>
Date: Sun, 09 Dec 2007 15:25:35 -0500

Hi Abhijit,

If your resource file is packaged inside ejb jar file as
META-INF/trackit_log.properties, you can access it from any class of the
same ejb:

InpuStream ins =
getClass().getResourceAsStream("/META-INF/trackit_log.properties");

Note the leading slash is used to indicate its an absolute path.
Otherwise the resource is assumed to be in the same package as the
referencing class.

-cheng

Abhijit Sarkar wrote:
> Hi,
> I have an ear in the following structure:
>
> trackit (ear)
> META-INF
> trackit_log.properties
> trackit_security.policy
> ...
> trackit-ejb
> ...
> trackit-war
> ...
>
> I'm trying to locate the file "trackit_log.properties" from within
> trackit-ejb. I'm using the relative path "META-INF/trackit_log.properties".
> I've tried using Thread.currentThread().getContextClassLoader() or
> <<Classname>>.getClassLoader and then getting the resource as Stream but in
> vain.
>
> Pls. pls help.
>
> Thanks n advance,
> Abhijit
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ejb-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: ejb-help_at_glassfish.dev.java.net
>
>