Created
October 29, 2010 11:55
-
-
Save cowboyd/653397 to your computer and use it in GitHub Desktop.
Why can't JRuby find it's
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Extension | |
public class RubyExtensionFinder extends ExtensionFinder { | |
public RubyExtensionFinder() { | |
ScriptingContainer jruby = new ScriptingContainer(); | |
/** | |
* When run in the maven test suite, this line executes just fine | |
* but when instantiated by the Hudson server at runtime, gets the | |
* following error: no such file to load -- builtin/core_ext/symbol | |
* | |
* What's the conventional way to help Jruby find its way home through | |
* a complex forest of class loaders? | |
*/ | |
/** | |
* the answer is this line right here. If I understand correctly, it makes | |
* sure that the ScriptContainer uses the same class loader for scripts as | |
* the one that loaded _it_ that way, it can find the jruby-complete.jar | |
* that contains the stardard ruby library. | |
*/ | |
jruby.setClassLoader(jruby.getClass().getClassLoader()); | |
jruby.runScriptlet("puts 'Hello From Hudson Extension Finder!'"); | |
} | |
public <T> Collection<ExtensionComponent<T>> find(Class<T> tClass, Hudson hudson) { | |
System.out.printf("find(%s)\n", tClass.getName()); | |
return new ArrayList<ExtensionComponent<T>>(); | |
} | |
} |
adding
ruby.setClassLoader(jruby.getClass().getClassLoader())
seems to do the trick. thanks!
Good to know that. You're welcome!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you are using jruby.jar, would you try jruby.setHomeDirectory([jruby's home directory here])? Unless, jruby.setClassLoader(jruby.getClass().getClassLoader()) or setting some suitable classloader might work.