Hi,

I think you need to use getResourceAsStream("/res/stock.txt"); (mind the / at 
the beginning)
Have you tried that?

BR,
Leander

> -----Ursprüngliche Nachricht-----
> Von: Seem [mailto:sim...@gmx.de]
> Gesendet: Montag, 15. Dezember 2008 19:56
> An: axis-user@ws.apache.org
> Betreff: get Resource inside .aar?
>
>
> Hi,
>
> I still have problems to access a file inside an .aar. I tried to
> extend the
> simple "quickstart" example from the axis2 repository, but I won't get
> access?!?!?!
>
> The .aar folder structure is
> META-INF/
> samples/...
> res/stock.txt
>
>
> here is my code:
>
> #########################################
> package samples.quickstart.service.pojo;
>
> import java.io.BufferedReader;
> import java.io.IOException;
> import java.io.InputStream;
> import java.io.InputStreamReader;
> import java.util.HashMap;
>
>
> public class StockQuoteService
> {
>     private HashMap map = new HashMap();
>
>     public double getPrice(String symbol) {
>                 StockQuoteService i = new StockQuoteService();
>         InputStream a =
> i.getClass().getClassLoader().getResourceAsStream("res/stock.txt");
>
> //      Thread thread = Thread.currentThread();
> //      ClassLoader loader = thread.getContextClassLoader();
> //      thread.setContextClassLoader(i.getClass().getClassLoader());
> //      InputStream a =
> Thread.currentThread().getContextClassLoader().getResourceAsStream("res
> /stock.txt");
>
>
>         return
> Double.valueOf(i.convertStreamToString(a)).doubleValue();
>     }
>
>     private String convertStreamToString(InputStream a)
>         {
>         BufferedReader reader = new BufferedReader(new
> InputStreamReader(a));
>     .....}
>
> }
> #########################################
> --
> View this message in context: http://www.nabble.com/get-Resource-
> inside-.aar--tp21019445p21019445.html
> Sent from the Axis - User mailing list archive at Nabble.com.


VVA Networks GmbH

Mario-Leander Reimer
Dipl.-Inf. (FH)
Teamleitung Publishing Solutions
---------------------------------------------------------------------------
VVA Networks GmbH
: medien mit zukunft
Geisenhausenerstraße 15-17
81379 München
Deutschland
---------------------------------------------------------------------------
Fon:    +49 89 2000375-610
Fax:    +49 89 2000375-699
Mobil:  +49 173 5883541
---------------------------------------------------------------------------
leander.rei...@vva-networks.de
www.vva-networks.de

-----------------------------------------------------------------------
HRB 33884 Düsseldorf
Geschäftsführer Rolf Christian Kassel
-----------------------------------------------------------------------
Ein Unternehmen der VVA Kommunikation
http://www.vva.de
-----------------------------------------------------------------------
omnisuite® - integrate. automate. communicate.
http://www.omnisuite.de
-----------------------------------------------------------------------

Diese Nachricht (inklusive aller Anhänge) ist vertraulich. Sie darf
ausschließlich durch den vorgesehenen Empfänger und Adressaten gelesen,
kopiert oder genutzt werden. Sollten Sie diese Nachricht versehentlich
erhalten haben, bitten wir, den Absender (durch Antwort-E-Mail) hiervon
unverzüglich zu informieren und die Nachricht zu löschen. Jede unerlaubte
Nutzung oder Weitergabe des Inhalts dieser Nachricht, sei es vollständig
oder teilweise, ist unzulässig.

This message (including any attachments) is confidential and may be
privileged. It may be read, copied and used only by the intended recipient.
If you have received it in error please contact the sender (by return
E-Mail) immediately and delete this message. Any unauthorised use or
dissemination of this message in whole or in part is strictly prohibited.

Reply via email to