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 D Sledge <va...@yahoo.com> on 2004/11/07 03:54:37 UTC

getResource() returning unexpected URL

Suppose I have a jar file called "myClasses.jar" containing a class file "MyClass.class" in the
package "package.of.files".  The jar file is in the directory
$AXIS_HOME/webapps/axis/WEB-INF/lib/.  Whenever I try to get the URL of the package via
Class.getResources() I get the URL:

    file:$CATALINA_HOME/work/Catalina/localhost/axis/loader/package/of/files

When the URL is actually:

    jar:file:$AXIS_HOME/webapps/axis/WEB-INF/lib/myClasses.jar!/package/of/files

When I go to the directory "$CATALINA_HOME/work/Catalina/localhost/axis/loader/", the directory
"package/of/files" does not exist.  The following is the code used to retrieve the URL of the
package:

      URL url = package.of.files.MyClass.class.getResource("");
      System.out.println(url.toString());

Is this a bug?  If not what is the reason I'm getting a false URL?

D Sledge


		
__________________________________ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com 
 


Re: getResource() returning unexpected URL -- P.S.

Posted by D Sledge <va...@yahoo.com>.
P.S.  The work around I've found for this is get use Class.getResource() to retrieve the URL of a
class file within the package instead of trying to retrieve the URL of the package itself.  When I
do this I get the correct URL.  From there I just strip the class file from it.


		
__________________________________ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com