JRuby

JRuby uses wrong classloader when trying to load required modules on GlassFish (when jruby.jar is in lib/ext)

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: JRuby 0.9.1, JRuby 0.9.2
  • Fix Version/s: JRuby 0.9.9
  • Component/s: Java Integration
  • Labels:
    None
  • Environment:
    Debian GNU/Linux, kernel 2.6.16.16, i686, GlassFish V2 b20
  • Number of attachments :
    0

Description

Initial setup:
GlassFish domain is located at ${domain}.
jruby.jar is located in ${domain}/lib/ext
Web application (WAR file), which contains a JAR file (later referred to as r.jar) in WEB-INF/lib which contains some ruby modules, is deployed into this domain.

When the web application tries to execute some external ruby script (using absolute path, passing it to org.jruby.Main.run() method), and the script requires a ruby module which is located in r.jar, JRuby engine cannot resolve this module. However, if jruby.jar is located in the WEB-INF/lib of the same web application, JRuby can load the required module.

NB: org.jruby.Main.run() is used because I need to hijack stdin/stdout/stderr of the script (I couldn't find how to do it using BSF)

Activity

Hide
Nick Sieger added a comment -

I've noticed this before when browsing the source code. Perhaps wherever Class.forName is used, the 3-arg version of Class.forName should be used instead with the Thread context class loader (if it's available). This would make embedding in managed environments or classloader hierarchies possible.

Show
Nick Sieger added a comment - I've noticed this before when browsing the source code. Perhaps wherever Class.forName is used, the 3-arg version of Class.forName should be used instead with the Thread context class loader (if it's available). This would make embedding in managed environments or classloader hierarchies possible.
Hide
Charles Oliver Nutter added a comment -

Upcoming patches for JRUBY-335 will likely fix this by having load use the Thread's context classloader rather than the classloader in which JRuby was loaded.

Show
Charles Oliver Nutter added a comment - Upcoming patches for JRUBY-335 will likely fix this by having load use the Thread's context classloader rather than the classloader in which JRuby was loaded.
Hide
Charles Oliver Nutter added a comment -

Still an issue?

Show
Charles Oliver Nutter added a comment - Still an issue?
Hide
Ivan Tarasov added a comment -

Just checked, it looks like it was fixed in trunk.

Show
Ivan Tarasov added a comment - Just checked, it looks like it was fixed in trunk.
Hide
Charles Oliver Nutter added a comment -

Gotta love mystery fixes.

Show
Charles Oliver Nutter added a comment - Gotta love mystery fixes.

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: