Hi,
I have a application that uses BSF to invoke JRuby scripts and since
JRuby
1.1.3 i’m getting this exception:
unable to load language: ruby: java.lang.NoClassDefFoundError:
org/apache/bsf/util/BSFEngineImpl
I had no problems with JRuby 1.1.2 or earlier.
I wrote a small app to show this issue.
$ cat testJava.rb
require ‘java’
include_class ‘TestBSF’
puts “Hello from Ruby”
bsf = TestBSF.new
$ cat TestBSF.java
import org.apache.bsf.BSFException;
import org.apache.bsf.BSFManager;
public class TestBSF {
public TestBSF() {
BSFManager bsfManager = new BSFManager();
String expression = "puts \"Hello from BSF\" ";
try {
bsfManager.eval("ruby", "TestBSF", -1, -1, expression);
}
catch (BSFException e) {
e.printStackTrace();
}
}
}
$ jruby testJava.rb
Hello from Ruby
unable to load language: ruby: java.lang.NoClassDefFoundError:
org/apache/bsf/util/BSFEngineImpl
at java.lang.ClassLoader.findBootstrapClass(Native Method)
at
java.lang.ClassLoader.findBootstrapClass0(ClassLoader.java:891)
at java.lang.ClassLoader.loadClass(ClassLoader.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at org.apache.bsf.BSFManager.loadScriptingEngine(Unknown Source)
at org.apache.bsf.BSFManager.eval(Unknown Source)
at TestBSF.(TestBSF.java:12)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.jruby.javasupport.JavaConstructor.new_instance(JavaConstructor.java:195)
at
org.jruby.javasupport.JavaConstructorInvoker$new_instance_method_0_0.call(Unknown
Source)
at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:279)
at org.jruby.ast.CallNode.interpret(CallNode.java:163)
at
org.jruby.ast.AttrAssignOneArgNode.interpret(AttrAssignOneArgNode.java:32)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:101)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:67)
at
org.jruby.internal.runtime.methods.DefaultMethod.interpretedCall(DefaultMethod.java:171)
at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:147)
at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:203)
at
org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:111)
at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:282)
at org.jruby.ast.FCallNode.interpret(FCallNode.java:139)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:101)
at
org.jruby.internal.runtime.methods.DefaultMethod.interpretedCall(DefaultMethod.java:171)
at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:147)
at org.jruby.RubyClass.invoke(RubyClass.java:243)
at
org.jruby.javasupport.util.RuntimeHelpers.invoke(RuntimeHelpers.java:270)
at org.jruby.RubyObject.callMethod(RubyObject.java:711)
at org.jruby.RubyClass.newInstance(RubyClass.java:275)
at
org.jruby.RubyClassInvoker$newInstance_method_0_0.call(Unknown
Source)
at
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:134)
at
org.jruby.internal.runtime.methods.AliasMethod.call(AliasMethod.java:76)
at
org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:111)
at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:282)
at org.jruby.ast.FCallNode.interpret(FCallNode.java:139)
at org.jruby.ast.LocalAsgnNode.interpret(LocalAsgnNode.java:115)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:101)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:67)
at
org.jruby.internal.runtime.methods.DefaultMethod.interpretedCall(DefaultMethod.java:171)
at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:147)
at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:224)
at
org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:123)
at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:333)
at
ruby.home.hugo.test_jruby_minus_1_dot_1_dot_3.testJava.file(testJava.rb:5)
at
ruby.home.hugo.test_jruby_minus_1_dot_1_dot_3.testJava.file(testJava.rb)
at
ruby.home.hugo.test_jruby_minus_1_dot_1_dot_3.testJava.load(testJava.rb)
at org.jruby.Ruby.runScript(Ruby.java:541)
at org.jruby.Ruby.runNormally(Ruby.java:454)
at org.jruby.Ruby.runFromMain(Ruby.java:327)
at org.jruby.Main.run(Main.java:194)
at org.jruby.Main.run(Main.java:91)
at org.jruby.Main.main(Main.java:82)
Any suggestions?
Thanks!
Regards,
Hugo Reis
Hugo Reis wrote:
import org.apache.bsf.BSFManager;
}
org/apache/bsf/util/BSFEngineImpl
Interesting…could you try running with --debug? I suspect the problem
is our fix to only load jruby.jar using the boot classloader. That could
certainly be a problem since bsf isn’t packaged into that jar file.
Have you filed a bug for this?
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
I opened a bug for this issue:
http://jira.codehaus.org/browse/JRUBY-2898
$ jruby --debug testJava.rb
Hello from Ruby
unable to load language: ruby: java.lang.NoClassDefFoundError:
org/apache/bsf/util/BSFEngineImpl
at java.lang.ClassLoader.findBootstrapClass(Native Method)
at
java.lang.ClassLoader.findBootstrapClass0(ClassLoader.java:891)
at java.lang.ClassLoader.loadClass(ClassLoader.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at org.apache.bsf.BSFManager.loadScriptingEngine(Unknown Source)
at org.apache.bsf.BSFManager.eval(Unknown Source)
at TestBSF.(TestBSF.java:12)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.jruby.javasupport.JavaConstructor.new_instance(JavaConstructor.java:195)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.jruby.internal.runtime.methods.ReflectedJavaMethod.call(ReflectedJavaMethod.java:143)
at
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:134)
at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:279)
at org.jruby.ast.CallNode.interpret(CallNode.java:163)
at
org.jruby.ast.AttrAssignOneArgNode.interpret(AttrAssignOneArgNode.java:32)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:101)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:67)
at
org.jruby.internal.runtime.methods.DefaultMethod.interpretedCall(DefaultMethod.java:171)
at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:147)
at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:203)
at
org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:111)
at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:282)
at org.jruby.ast.FCallNode.interpret(FCallNode.java:139)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:101)
at
org.jruby.internal.runtime.methods.DefaultMethod.interpretedCall(DefaultMethod.java:171)
at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:147)
at org.jruby.RubyClass.invoke(RubyClass.java:243)
at
org.jruby.javasupport.util.RuntimeHelpers.invoke(RuntimeHelpers.java:270)
at org.jruby.RubyObject.callMethod(RubyObject.java:711)
at org.jruby.RubyClass.newInstance(RubyClass.java:275)
at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.jruby.internal.runtime.methods.ReflectedJavaMethod.call(ReflectedJavaMethod.java:143)
at
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:134)
at
org.jruby.internal.runtime.methods.AliasMethod.call(AliasMethod.java:76)
at
org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:111)
at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:282)
at org.jruby.ast.FCallNode.interpret(FCallNode.java:139)
at org.jruby.ast.LocalAsgnNode.interpret(LocalAsgnNode.java:115)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:101)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:67)
at
org.jruby.internal.runtime.methods.DefaultMethod.interpretedCall(DefaultMethod.java:171)
at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:147)
at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:224)
at
org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:123)
at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:333)
at org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:61)
at org.jruby.ast.LocalAsgnNode.interpret(LocalAsgnNode.java:115)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:101)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:67)
at org.jruby.ast.RootNode.interpret(RootNode.java:126)
at org.jruby.Ruby.runInterpreter(Ruby.java:561)
at org.jruby.Ruby.runNormally(Ruby.java:460)
at org.jruby.Ruby.runFromMain(Ruby.java:327)
at org.jruby.Main.run(Main.java:194)
at org.jruby.Main.run(Main.java:91)
at org.jruby.Main.main(Main.java:82)
Thanks,
Hugo
On Mon, Aug 4, 2008 at 1:36 AM, Charles Oliver N. <