Ok. I have figured this out :>
Prereqs: JBoss App Server with Tomcat serlvet container - XFire lib.

When you have a file in such location (war packaging):
WEB-INF/classes/META-INF/myfile.xml
you can load it like this:
Thread.currentThread().getContextClassLoader().getResourceAsStream(META-INF/myfile.xml);

When you have your file in : WEB-INF/classes/my/package/myfile.xml
and you try to load this file from Java source file which is located in the
same package : WEB-INF/classes/my/package/myservice.class 
you can load it like this:
this.getClass().getResourceAsStream("myfile.xml");

Hope that helps.
Regards,
Tom 

P.S. This link is also helpful :
http://www.javaworld.com/javaqa/2003-08/01-qa-0808-property_p.html?page=1


szefo wrote:
> 
> The method that you have described (ClassLoader.getResourceAsStream) does
> not seem to work.
> That's my war folder structure: (generated by maven2)
> 
> xfire-sample-project.war
>   | - WEB-INF
>   |    | - lib (all jar files)
>   |    | - myconfig.xml (my-configuration file-> which i need to open from
> @WebMethod))
>   |    | - web.xml
>   |    | - classes
>   |           | - META-INF
>   |           |      | - xfire
>   |           |            | - services.xml
>   |           |
>   |           | -pl
>   |              | - xfire
>   |                    | - service
>   |                            | - myService.class
>   | - META-INF
>   |         | - MANIFEST.MF
>   |         | - ...
>   |
> WEB-INF/NamingServiceConfiguration.xml
> I have treid many times with different paths but I cannot open the
> myconfig.xml file...
> This invocation is located in myService.class
> - ClassLoader.getResourceAsStream("WEB-INF/myconfig.xml")
> - ClassLoader.getResourceAsStream("/WEB-INF/myconfig.xml")
> - ClassLoader.getResourceAsStream("myconfig.xml")
> 
> I also put the myconfig file to the folder where myService.class is
> located and tried:
> - ClassLoader.getResourceAsStream("myconfig.xml")
> -
> ClassLoader.getResourceAsStream("WEB-INF/classes/pl/xfire/service/myconfig.xml")
> -
> ClassLoader.getResourceAsStream("/WEB-INF/classes/pl/xfire/service/myconfig.xml")
> - ClassLoader.getResourceAsStream("pl/xfire/service/myconfig.xml")
> - ClassLoader.getResourceAsStream("/pl/xfire/service/myconfig.xml")
> 
> What am I doing wrong? Where is the mistake? Could someone specify how I
> should open the myconfig.xml file?
> Many thanks in advance.
> Tom
> 
> 
> szefo wrote:
>> 
>> How should I define such resource. Should the definition be in the
>> servlet's web.xml? I have seen that there are many syntaxes? Hos the
>> definition should look like?
>> Thanks!
>> 
>> 
>> Tomek Sztelak wrote:
>>> 
>>> You can obtain inputstream which contains file data with
>>> ClassLoader.getResourceAsStream
>>> 
>>> On 5/7/07, szefo <[EMAIL PROTECTED]> wrote:
>>>>
>>>> I have a another question. I don't need to modify this file but only
>>>> read.
>>>> Imagine a siutation when a service is deployed in a war file with a
>>>> confioguration.xml file - where the configuration settings are stored.
>>>> How
>>>> can I obtain a relative path to this file?
>>>> Many thanks in advance ;)
>>>>
>>>>
>>>>
>>>> Tomek Sztelak wrote:
>>>> >
>>>> > First hint : don't do it :). Modifying file inside deployed webapp is
>>>> > tricky business, what if your webapp isn't unpacked ?
>>>> > If you have file you need to modify then place is somewhere outside
>>>> > app, maybe in db or so.
>>>> >
>>>> > On 4/25/07, Wacław Borowiec <[EMAIL PROTECTED]> wrote:
>>>> >> Hello
>>>> >>
>>>> >> How to obtain a relative path of a service? What is an actual
>>>> problem: I
>>>> >> try
>>>> >> to dynamicaly modify a trust store for a web service securisty, so I
>>>> have
>>>> >> to
>>>> >> create an OutputStream with an absolute path (using JBoss, relative
>>>> path
>>>> >> doesn't work) when saving the trust store file. But in WSS4J
>>>> properties
>>>> >> file, I pass a relative path to the trust store. So how to to save a
>>>> file
>>>> >> inside the deployed XFire application?
>>>> >>
>>>> >> thank for any help
>>>> >> Wacław Borowiec
>>>> >>
>>>> >>
>>>> >>
>>>> >
>>>> >
>>>> > --
>>>> > -----
>>>> > When one of our products stops working, we'll blame another vendor
>>>> > within 24 hours.
>>>> >
>>>> >
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/service-local-path-tf3646760.html#a10359230
>>>> Sent from the XFire - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list please visit:
>>>>
>>>>     http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>> 
>>> 
>>> -- 
>>> -----
>>> When one of our products stops working, we'll blame another vendor
>>> within 24 hours.
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/service-local-path-tf3646760.html#a10391076
Sent from the XFire - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to