Fork me on GitHub

Deprecated version of JRuby for JRubyJar

Table of Contents

What’s going on?

Starting with JRuby 1.7.20 there were substantial improvements introduced to JRuby core which make running JRuby in an "embedded" scenario more reliable. Packing a JRubyJar being a fairly typical "embedded JRuby" use-case, there is certain functionality that relies on these improvements.

This does not mean older versions of JRuby won’t work in JRubyJar archives but rather: you are likely going to experience problems with a more complex use-case on an older JRuby. For example, Rails applications will not function properly if embedded in a .jar with JRuby 1.7.19.

How to fix it

Since JRuby/Gradle 1.0 and later default to 9.0.0.0 and later, the easiest fix is to stop overriding the default (read: latest stable) JRuby version enummerated by the plugin.

If the latest is viable for the project you’re working with, at least update the version to something later than 1.7.22 via:

build.gradle
jruby {
    defaultVersion '1.7.22'
}

Okay that didn’t work

If for whatever reason you cannot upgrade your version of JRuby, you can try to disable the embedded behavior in the JRubyJar and switch Jar’s Main-Class to a "self-extracting" main provided by jruby-mains.

This is untested as of this document’s writing but the basic idea is that instead of trying to execute the Ruby code from a fully embedded scenario, the self-extracting Main will first unzip the jar file into /tmp before setting up the JRuby environment.

build.gradle
jrubyJar {
    mainClass 'org.jruby.mains.ExtractingMain'
}
  • issue #191 outlines the feature request that led to this behavior being introduced


improve this page