Hi,

I put the file in the root folder of the AAR (not in the package
folders).  I pass only a filename to the getResourceAsStream() without
any absolute or relative path.

-Carl

-----Original Message-----
From: Grimm, Markus [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 18, 2008 9:18 AM
To: [email protected]
Subject: READ a resource inside an aar

Hi all,

a question similar to this message-context [1]

[1]
http://www.nabble.com/Path-to-a-resource-inside-an-aar-tp19506606p195083
56.html


I followed Deepal's link to http://wso2.org/library/259 and tried to
read a file inside the service-archive (*.aar). 
the file is in the same folder as the ServiceImpl-class and the
SerciveImpl-class wants to read the file as an inutStream.

I tried both ways:

>       MessageContext ctx = MessageContext.getCurrentMessageContext();
>       AxisService svc = ctx.getAxisService();
>       ClassLoader loader = svc.getClassLoader();
>       String filename = (String)svc.getParameterValue("file.txt");
>       InputStream is = loader.getResourceAsStream(filename);

and

>getClass().getClassLoader().getResourceAsStream("file.txt");

Both ways don't find the file. If I debug my read-method, the loader
shows in both cases:

WebappClassLoader
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
[EMAIL PROTECTED]

So, if I put the 'file.txt' to the /WEB-INF/classes/ -folder, I can read
the file.
How can I get the classloader of the single service, so I can read a
resouce that resides inside of an archive ?

Thanks,
Markus

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Confidentiality Notice:  This email, including attachments, may include 
non-public, proprietary, confidential or legally privileged information.  If 
you are not an intended recipient or an authorized agent of an intended 
recipient, you are hereby notified that any dissemination, distribution or 
copying of the information contained in or transmitted with this e-mail is 
unauthorized and strictly prohibited.  If you have received this email in 
error, please notify the sender by replying to this message and permanently 
delete this e-mail, its attachments, and any copies of it immediately.  You 
should not retain, copy or use this e-mail or any attachment for any purpose, 
nor disclose all or any part of the contents to any other person. Thank you


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to