You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Smith, Larry" <xl...@ti.com> on 2002/09/12 21:50:38 UTC

Finding a WEB Service's Directory

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
specific
to my service, and its intallation directory would seem to be the right
place.

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
vary
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");
and
	URL = getClass.getClassLoader.getSystemResource("test.txt");
and
	URL =
MessageContext.getCurrentContext.getClassLoader.getResource("test.txt");

None of the above worked.

Thanks & Regards,
Larry