Forum: JRuby cannot load Java class jline.console.ConsoleReader

05d9948ffac2a58b6747a8028c1061d6?d=identicon&s=25 Khirod Patra (khirodjruby)
on 2014-05-20 09:36
JRUBY : 1.7.8


I am getting the classloader issue for jline. When I tired to debug with
pry it load the jline class successfully , but without debug mode it
just failed to load the class.

Other related information:
-----------------------------

I am using my project.jar which have included
jruby-core-complete-1.7.8.jar and jruby-stdlib-complete-1.7.8.jar. I
checked manually the jline package included in the
jruby-stdlib-complete-1.7.8.jar, but the log says it looks from
jruby-core-complete-1.7.8.jar , not sure. Please help.



Log:
----------

[2014-05-20 10:42:34] ERROR Object: <NameError> cannot load Java class
jline.console.ConsoleReader
  org/jruby/javasupport/JavaClass.java:1250:in `for_name'
  org/jruby/javasupport/JavaUtilities.java:34:in `get_proxy_class'
  file:/tmp/jruby882017107996340294extract/jruby-core-complete-1.7.8.jar!/jruby/java/core_ext/object.rb:26:in
`java_import'
  org/jruby/RubyArray.java:2413:in `map'
  file:/tmp/jruby882017107996340294extract/jruby-core-complete-1.7.8.jar!/jruby/java/core_ext/object.rb:22:in
`java_import'


Thanks
-Khirod
05d9948ffac2a58b6747a8028c1061d6?d=identicon&s=25 Khirod Patra (khirodjruby)
on 2014-05-20 09:41
I just tried with set the CLASSPATH for jruby-complete-1.7.8.jar
externaly, but still it is failing with same reason.

2014-05-20 13:09:07] ERROR Object: <NameError> cannot load Java class
jline.console.ConsoleReader
  org/jruby/javasupport/JavaClass.java:1250:in `for_name'
  org/jruby/javasupport/JavaUtilities.java:34:in `get_proxy_class'
  file:/home/eip/installer/lib/jruby-complete-1.7.8.jar!/jruby/java/core_ext/object.rb:26:in
`java_import'
  org/jruby/RubyArray.java:2413:in `map'
  file:/home/eip/installer/lib/jruby-complete-1.7.8.jar!/jruby/java/core_ext/object.rb:22:in
`java_import'


-khirod
05d9948ffac2a58b6747a8028c1061d6?d=identicon&s=25 Khirod Patra (khirodjruby)
on 2014-05-20 09:55
Now , I just extract the jline.jar from jruby-complete-1.7.8.jar and
export in the CLASSPATH externally and it works fine. But I want to use
the jline from jruby-complete-1.7.8.jar. Please help!


-Khirod
B05d3cbc64b0031a24c2887fb6ddc173?d=identicon&s=25 christian (Guest)
on 2014-05-20 10:01
(Received via mailing list)
when I execute something like this:

$ java -jar jruby-complete-1.7.8.jar -e 'p require"readline";p
$CLASSPATH'

things looks OK on my side. how do you execute jruby ?

does it help if you require 'readline/jline-2.11' explicitly - something
like

$ java -jar jruby-complete-1.7.8.jar -e 'p
require"readline/jline-2.11";p
$CLASSPATH'

?
05d9948ffac2a58b6747a8028c1061d6?d=identicon&s=25 Khirod Patra (khirodjruby)
on 2014-05-20 13:36
Hi Christian,

Thanks for your help. I tried your command it works fine in prompt. How
can I used it my code? Do I have to use always pry , can't we load the
class without pry.Please help.



java -jar jruby-complete-1.7.8.jar -e 'p require "readline/jline-2.11";p
$CLASSPATH'
true


Thanks
-Khirod
B05d3cbc64b0031a24c2887fb6ddc173?d=identicon&s=25 christian (Guest)
on 2014-05-20 13:52
(Received via mailing list)
just add

require 'readline/jline-2.11'

before you want to use jline classes. let me know if that solves your
problem so I can improve things on the jruby side of things.
05d9948ffac2a58b6747a8028c1061d6?d=identicon&s=25 Khirod Patra (khirodjruby)
on 2014-05-20 13:53
Hi Christian,

In the code I tried

p require "readline/jline-2.11"
p $CLASSPATH

It loaded successfully i.e.

true

["file:/home/Khirod/myproject/lib/ojdbc6.jar",
"file:/home/Khirod/myproject/lib/jruby-complete-1.7.8.jar",
"file:/home/Khirod/myproject/lib/mycustom.jar",
"jar:file:/tmp/jruby5839733601718663013extract/jruby-stdlib-complete-1.7.8.jar!/META-INF/jruby.home/lib/ruby/shared/readline/jline-2.11.jar"]

I used the java_import to load ConsoleReader i.e.

java_import 'jline.console.ConsoleReader' Here it is still failed to
load the class jline.console.ConsoleReader.


Thanks
-Khirod
B05d3cbc64b0031a24c2887fb6ddc173?d=identicon&s=25 christian (Guest)
on 2014-05-20 14:13
(Received via mailing list)
I am sure this works for you as well:

java -jar
/usr/local/repository/org/jruby/jruby-complete/1.7.8/jruby-complete-1.7.8.jar
t.rb -e "require 'readline';java_import 'jline.console.ConsoleReader'; p
ConsoleReader.new"


from your classpath above I see jruby-stdlib-complete-1.7.8.jar and
jruby-complete-1.7.8.jar - there is something TOO much. jruby-complete
is
jruby-core-complete + jruby-stdlib-complete ! so when you are using
jruby-complete please leave those other jars out of the classpath. hope
that helps you a step further ;)
05d9948ffac2a58b6747a8028c1061d6?d=identicon&s=25 Khirod Patra (khirodjruby)
on 2014-05-20 18:02
Thanks Christian,

The tricks works. Thanks for your suggestions.

-Khirod
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.