0

I'm trying to use JRuby 1.7.4 within a Java webapp. Here's the code I'm trying to run:

require 'strscan'
scanner = StringScanner.new("test\ntest\n")
scanner.bol?

this is being executed using the following Java code:

    ScriptEngineManager manager = new ScriptEngineManager();
    ScriptEngine engine = manager.getEngineByName("jruby");
    InputStream resourceAsStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("test.rb");
    InputStreamReader inputStreamReader = new InputStreamReader(resourceAsStream, Charset.forName("UTF-8"));
    engine.eval(inputStreamReader);

Unfortunately it ends up with this exception:

NoMethodError: undefined method `bol?' for nil:NilClass
  (root) at <script>:3

javax.script.ScriptException: org.jruby.embed.EvalFailedException: (NoMethodError) undefined method `bol?' for nil:NilClass
    at org.jruby.embed.jsr223.JRubyEngine.wrapException(JRubyEngine.java:104)
    at org.jruby.embed.jsr223.JRubyEngine.eval(JRubyEngine.java:121)
    at org.jruby.embed.jsr223.JRubyEngine.eval(JRubyEngine.java:146)

Any idea what could be wrong?

1 Answers1

-1

Solution was quite hard to find, it seems to be linked to Intellij Idea which adds the following path in the classpath which makes the test failed:

C:\Users\theaterofthought\.IntelliJIdea12\config\plugins\ruby\rubystubs\rubystubs18

Clearing and recreating the IDEA project helped to get a new launcher for my test working without this path in the -classpath argument.