Error in canonicalizePath with loading tryResourceFromJarURL ------------------------------------------------------------
Key: JRUBY-4875 URL: http://jira.codehaus.org/browse/JRUBY-4875 Project: JRuby Issue Type: Bug Components: Core Classes/Modules Affects Versions: JRuby 1.5.1 Environment: Man Reporter: Garrett Conaty The error first manifested itself when using Nick Sieger's Warbler with the new 'gemjar' option. Effectively loading Ruby classes from embedded JARs within a WAR fails because tryResourceFromJarURL calls canonicalizePath which trims too much of the filename. The trouble is here: String cwd = new File(runtime.getCurrentDirectory()).getCanonicalPath(); return new File(path).getCanonicalPath() .substring(cwd.length() + 1) .replaceAll("\\\\","/"); Basically the runtime.getCurrentDirectory is /jetty/webapps/WEB-INF (WEB-INF is used as the RAILS_ROOT/MERB_ROOT), yet the default behavior for File(path).getCanonicalPath() would be to use the System property user.dir. These don't match. I've attached both a standalone test case and a patch. The patch is also available on my github fork. Note that in the patch I just remove the call to canonocalizePath for 2 reasons 1) The path is already in a JAR file my.jar!a/b/c hence it doesn't need to map to the underlying FS 2) This method is only called by tryResourceFromJarURL. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email