After a couple side conversations, I was able to get some resolution. It turns out that the ruby engine was not being properly initialized, but code has been checked into the jsr-233 project which will address it (though the proper place is likely in jruby, the person I was talking to has access to the one project's repo  but not the other). That allowed me to run my ruby unit test.
From there I continued to get an exception after it ran, which turns out to be a 'feature' of how test::unit is run. In it's at_exit call, it is using the 'exit' keyword which does not work in the jsr-233 context. Editing it to remove the offending call completely addressed the problem.
So I can now access both python unittest and ruby test::unit tests from within a single jython script. Those unit tests would largely be selenium rc scripts written by the development team in whichever language they feel most productive in. I just wish the jruby tests were first class objects instead of just pumping text through an interpreter object (which seems kinda inelegant).

Subject: RE: [Jython-users] jruby inside jython
Date: Tue, 20 Nov 2007 10:14:05 -0600


Iím not sure if you got any sort of response. so Iíll provide what I can so you donít feel like youíve been forgotten. J

First a disclaimer, I know very little about Ruby / jRuby.


Wrt running jruby inside Jython. I havenít heard of, or seen any reference to any doing anything like that. Honestly in my mind it begs the question; why would I want to do that any way? Could jython be run from jrubyÖ.would I even want to do that?


Based on the stack dump that you provided Iíd say that it looks like the error is coming from jruby, but I could be wrong. This is a pretty esoteric question so I suspect there are very few that have even tried it.  My best suggestion is try the ruby lists again. I know Charles Nutter has some experience with both Jython and JRuby but I donít if even he would have tried this.




From: [] On Behalf Of adam goucher
Sent: Thursday, November 15, 2007 7:41 PM
Subject: [Jython-users] jruby inside jython


I originally sent this to the jruby list, but did not get any solutions. Has anyone on this side of things had success running jruby inside jython for running ruby unit tests?

(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.
require 'test/unit'
class ExampleTest < Test::Unit::TestCase
    def test_something
        p "ruby!"
    def test_another
        p "again!"
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(
Traceback (innermost last):
  File "", 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(
        from org.jruby.Ruby.tearDown(
        from org.jruby.javasupport.JavaEmbedUtils.terminate(
        from com.sun.script.jruby.JRubyScriptEngine.evalNode(
        from com.sun.script.jruby.JRubyScriptEngine.eval(
        from javax.script.AbstractScriptEngine.eval(
        from sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        from sun.reflect.NativeMethodAccessorImpl.invoke(
        from sun.reflect.DelegatingMethodAccessorImpl.invoke(
        from java.lang.reflect.Method.invoke(
        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(
        from org.python.pycode._pyx0.call_function(
        from Source)
        from 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

Are you ready for Windows Live Messenger Beta 8.5 ? Get the latest for free today!


Have fun while connecting on Messenger! Click here to learn more.

This message and any attachments are intended only for the use of the addressee and may contain information that is privileged and confidential. If the reader of the message is not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail and delete the message and any attachments from your system.

Have fun while connecting on Messenger! Click here to learn more.