"No such file or directory (IOError)" when JAR file named in java.class.path
but not active filesystem
------------------------------------------------------------------------------------------------------
Key: JRUBY-2782
URL: http://jira.codehaus.org/browse/JRUBY-2782
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Affects Versions: JRuby 1.1.2
Reporter: Eric Sirianni
ScriptEngineFactory scriptEngineFactory = new JRubyScriptEngineFactory();
ScriptEngine scriptEngine = scriptEngineFactory.getScriptEngine();
scriptEngine.eval("puts 'Hello World'");
The call to new JRubyScriptEngineFactory() generates this exception:
No such file or directory
:1: No such file or directory (IOError)
...internal jruby stack elided...
After some serious digging it looks like the problem was that there was a JAR
file
foo.jar in "java.class.path" (i.e. java -cp ....:/path/to/foo.jar:... ) that was
not present in the active file system.
LoadService.findFile() {
...
if(null == current) {
try {
if(entry.startsWith("jar:")) {
current = new JarFile(entry.substring(4));
} else if (entry.endsWith(".jar")) {
current = new JarFile(entry);
} else {
current = new
JarFile(entry.substring(5,entry.indexOf("!/")));
}
jarFiles.put(entry,current);
} catch (FileNotFoundException ignored) {
>>> } catch (IOException e) {
throw runtime.newIOErrorFromException(e);
}
}
This line above was getting a java.util.zip.ZipException: No such file or
directory
Two things...
1. It seems bad to be iterating over java.class.path to find resources since
there are other ways of defining the application's classpath (MANIFESTS, war
files, etc.)
2. Your "FileNotFoundException ignored" is not being caught because ZipException
is not a subclass of FileNotFoundException
--
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