Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.1.2
-
Fix Version/s: JRuby 1.2
-
Component/s: Core Classes/Modules
-
Labels:None
-
Number of attachments :
Description
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:"))
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
Also, you are squelching the stack trace and the of the IOException, making it very difficult to debug.
Ruby.java
public RaiseException newIOErrorFromException(IOException ioe)
{ return newRaiseException(getIOError(), ioe.getMessage()); }You should be chaining the IOException into the new RaiseException