axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Neward <>
Subject RE: Finding a WEB Service's Directory
Date Thu, 12 Sep 2002 20:12:57 GMT
I can't remember off the top of my head--is there a way to get hold of the
servlet's ServletContext object from within an Axis service? That's got the
getResource() (and getResourceAsStream()) method, which operates directly
from the webapp's root directory.

I'm somewhat surprised that getClass().getClassLoader().getResource() didn't
work, though.

Ted Neward
Architect, UCDavis Account & Financial Services

-----Original Message-----
From: Andrew Vardeman []
Sent: Thursday, September 12, 2002 13:00
Subject: Re: Finding a WEB Service's Directory


this gets you to the WEB-INF directory in the webapp.  I'm saving service 
configuration stuff there, though there have been some threads where people 
have suggested cleaner ways of getting configuration information.


At 02:50 PM 9/12/2002 -0500, you wrote:

>How do I find the directory where my service's '.class' files reside (and
>from which they were loaded)?  I need to be able to read/write files
>to my service, and its intallation directory would seem to be the right 
>Using Tomcat 4.0.4 and Axis beta 3, File() creates and opens always go to
>the <CATALINA_HOME>/bin directory. In other words:
>         File(".").getAbsolutePath();
>returns "C:\jakarta-tomcat-4.0.4\bin\."
>I do not wish to hard-code the path to my service
>(ie: <CATALINA_HOME>/webapps/axis/WEB-INF/classes/myservice) since it will 
>for each deployment container used (WEB Logic, Tomcat, etc).
>The file "test.txt" exists in the "myservice" subdirectory -and- in
>the "myservice/resource" subdirectory; I've tried:
>         URL = getClass.getClassLoader.getResource("test.txt");
>         URL = getClass.getClassLoader.getSystemResource("test.txt");
>         URL = 
> MessageContext.getCurrentContext.getClassLoader.getResource("test.txt");
>None of the above worked.
>Thanks & Regards,

View raw message