logo       

Re: [jruby-user] jruby inside jython: msg#00139

lang.jruby.user

Subject: Re: [jruby-user] jruby inside jython

I think the problem is your jython code doesn't set the path to Ruby
scripts resides in test/unit directory. As for Java, setting a system
property, "com.sun.script.jruby.loadpath," before getting a instance
of JRuby's engine might resolve this kind of errors.

String loadPath =
"C:/temp/jpythonruby/jruby-1.0.2/lib/ruby/1.8";
System.setProperty("com.sun.script.jruby.loadpath", loadPath);
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("jruby");

But, sorry, I don't know how to set a system property by jython.

-Yoko

On Nov 15, 2007 10:34 AM, adam goucher <adam_goucher@xxxxxxxxxxx> wrote:
>
> (I tried to search the archives, but it wasn't working...)
>
> I'm trying to use JRuby in Jython via the JSR-233 engine. The ruby script
> is a Test::Unit::TestCase originating one and runs from the command line
> using the regular ruby interpreter. When I try to run it from it from inside
> my script however, things get ugly. I'm rather confused as to why it is
> blowing up in the way it is, but realize that it might be something trivial
> to make it work and having hit the 'spent enough time not figuring it out'
> its off to the mailing list.
>
> So can anyone shed light into the origin of the backtrace or have solved
> this problem a different way?
>
> Note: r.eval('puts "Hello!"') works fine, it is just when I pass in this
> script that it does not work.
>
> Thanks.
>
> -adam
> http://adam.goucher.ca
>
> <ruby>
> require 'test/unit'
> class ExampleTest < Test::Unit::TestCase
> def test_something
> p "ruby!"
> end
> def test_another
> p "again!"
> end
> end
> </ruby>
>
> <jython>
> import javax.script.ScriptContext
> import javax.script.ScriptEngine
> import javax.script.ScriptEngineManager
> import javax.script.ScriptException
>
> m = javax.script.ScriptEngineManager()
> r = m.getEngineByName("jruby")
> rs = open(f, "r")
> y = r.eval(rs.read())
> rs.close()
> </jython>
>
> <ugliness>
> Traceback (innermost last):
> File "jpythonruby.py", line 48, in ?
> C:/temp/jpythonruby/jruby-1.0.2/lib/ruby/1.8/test/unit/autorunner.rb:59:
> private
> method `sub' called for nil:NilClass (NoMethodError)
> from C:/temp/jpythonruby/jruby-1.0.2/lib/ruby/1.8/test/unit.rb:2:in
> `call'
> from
> C:/temp/jpythonruby/jruby-1.0.2/lib/ruby/1.8/test/unit/autorunner.rb:198:in
> `run'
> from
> C:/temp/jpythonruby/jruby-1.0.2/lib/ruby/1.8/test/unit/autorunner.rb:13:in
> `run'
> from C:/temp/jpythonruby/jruby-1.0.2/lib/ruby/1.8/test/unit.rb:278
> from <unknown>:1
> ...internal jruby stack elided...
> from org.jruby.runtime.Block.yield(Block.java:260)
> from org.jruby.runtime.Block.call(Block.java:214)
> from org.jruby.RubyProc.call(RubyProc.java:169)
> from org.jruby.RubyProc.call(RubyProc.java:148)
> from org.jruby.Ruby.tearDown(Ruby.java:1447)
> from
> org.jruby.javasupport.JavaEmbedUtils.terminate(JavaEmbedUtils.java:66)
> from
> com.sun.script.jruby.JRubyScriptEngine.evalNode(JRubyScriptEngine.java:396)
> from
> com.sun.script.jruby.JRubyScriptEngine.eval(JRubyScriptEngine.java:139)
> from
> javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
> from sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> from
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> from
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> from java.lang.reflect.Method.invoke(Method.java:597)
> from org.python.core.PyReflectedFunction.__call__(Unknown Source)
> from org.python.core.PyMethod.__call__(Unknown Source)
> from org.python.core.PyObject.__call__(Unknown Source)
> from org.python.core.PyInstance.invoke(Unknown Source)
> from org.python.pycode._pyx0.f$0(jpythonruby.py:48)
> from org.python.pycode._pyx0.call_function(jpythonruby.py)
> from org.python.core.PyTableCode.call(Unknown Source)
> from org.python.core.PyCode.call(Unknown Source)
> from org.python.core.Py.runCode(Unknown Source)
> from org.python.core.__builtin__.execfile_flags(Unknown Source)
> from org.python.util.PythonInterpreter.execfile(Unknown Source)
> from org.python.util.jython.main(Unknown Source)
> org.jruby.exceptions.RaiseException: org.jruby.exceptions.RaiseException
> </ugliness>
>
> ________________________________
> Are you ready for Windows Live Messenger Beta 8.5 ? Get the latest for free
> today!

---------------------------------------------------------------------
To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise