ejb@glassfish.java.net

Re: Problem resolving relative path within ear

From: Cheng Fang <Cheng.Fang_at_Sun.COM>
Date: Wed, 12 Dec 2007 17:14:12 -0500
Hi Abhijit,

EAR/meta-inf is not a good place for placing loadable resources, since it's not available in the application classloader chain.  I can't think of a good way to do that.  If you really want to put resource there to make it available to all modules, you can package the resource files in a jar file under EAR/lib directory.

-cheng

Abhijit Sarkar wrote:
Hi Cheng,
Thanks for your reply. But in my case the resource file is NOT in the same
ejb-jar as the class using it. The resource file is in ear META-INF. The ear
also has an ejb module. From within this module I'm accessing the file. Pls
refer to the project tree in my 1st mail.

Regards,
Abhijit


-----Original Message-----
From: Cheng Fang [mailto:Cheng.Fang@Sun.COM] 
Sent: Monday, December 10, 2007 1:56 AM
To: ejb@glassfish.dev.java.net
Subject: Re: Problem resolving relative path within ear

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@glassfish.dev.java.net
For additional commands, e-mail: ejb-help@glassfish.dev.java.net

  
    

---------------------------------------------------------------------
To unsubscribe, e-mail: ejb-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: ejb-help@glassfish.dev.java.net