Hi All,
I recently started working on packaging up a project I’ve been working
on,
and one of the requirements has been to compile ruby source into class
files to be jarred up for distribution. I’ve struggled through a
million
little issues, bouncing back and forth between rawr, warbler, and just
doing it myself with rake, and finally realized that (in addition to?)
other problems, the fundamental issue is that the class files produced
by
jrubyc throw an exception when executing in the JRE. Here’s the deal:
java -version
java version “1.7.0_07”
Java™ SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot™ 64-Bit Server VM (build 23.3-b01, mixed mode)
jruby -v
jruby 1.7.0 (1.9.3p203) 2012-10-22 ff1ebbe on Java HotSpot™ 64-Bit
Server VM 1.7.0_07-b10 [darwin-x86_64]
cat com/sas/solstice/agent/main.rb
puts “Hello, Mark!”
jruby -S jrubyc com/sas/solstice/agent/main.rb
(produces the exact same file as “jrubyc
com/sas/solstice/agent/main.rb”,
btw)
java -cp .:lib/java/jruby-complete.jar com.sas.solstice.agent.main
Exception in thread “main” java.lang.NoSuchMethodError:
org.jruby.javasupport.util.RuntimeHelpers.preLoad(Lorg/jruby/runtime/ThreadContext;Ljava/lang/String;Z)V
at com.sas.solstice.agent.main.load(com/sas/solstice/agent/main.rb)
at com.sas.solstice.agent.main.main(com/sas/solstice/agent/main.rb)
jruby com/sas/solstice/agent/main.rb
Hello, Mark!
jruby com/sas/solstice/agent/main.class
Hello, Mark!
Google tells me (thanks to this mailing list) that at least one other
person has run into similar issues trying to run a webapp in Tomcat, but
I’m guessing all the additional variables in that setup might have
masked
the actual problem. There also seems to be an open bug report (
http://jira.codehaus.org/browse/JRUBY-7050) triggered by failing unit
tests, but it doesn’t look like anyone has really investigated.
Is anyone else aware of this? Are there possibly known workarounds?
NoSuchMethodError makes me think that maybe there was a refactoring at
some point that broke something that got overlooked. Just browsing the
source, I noticed that
https://github.com/jruby/jruby/blob/master/src/org/jruby/javasupport/util/RuntimeHelpers.java
looks like:
package org.jruby.javasupport.util;
import org.jruby.runtime.Helpers;
@Deprecated
public class RuntimeHelpers extends Helpers {
}
This seems like a very promising lead for the given error, but I don’t
have the context to follow it. It also tells me that, in spite of the
subject of this email, jrubyc is probably doing its job right, but the
jruby runtime needs a bit of tweaking. Any thoughts?
Thanks so much!
Mark