无法加载Java类kafka.consumer.ConsumerIterator

时间:2015-05-10 11:49:35

标签: java ruby gem rvm jruby

我使用以下宝石 https://github.com/joekiller/jruby-kafka

我安装了java:

$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

并使用

jruby-1.7.19

成功后bundle install尝试执行我的应用时出现以下错误

NameError: cannot load Java class kafka.consumer.ConsumerIterator
for_name at org/jruby/javasupport/JavaClass.java:1286
get_proxy_class at org/jruby/javasupport/JavaUtilities.java:34
java_import at file:/home/user/.rvm/rubies/jruby-1.7.19/lib/jruby.jar!/jruby/java/core_ext/object.rb:27
map at org/jruby/RubyArray.java:2412
java_import at file:/home/user/.rvm/rubies/jruby-1.7.19/lib/jruby.jar!/jruby/java/core_ext/object.rb:22
Consumer at /home/user/.rvm/gems/jruby-1.7.19/gems/jruby-kafka-1.4.0-java/lib/jruby-kafka/consumer.rb:6
(root) at /home/user/.rvm/gems/jruby-1.7.19/gems/jruby-kafka-1.4.0-java/lib/jruby-kafka/consumer.rb:5
require at org/jruby/RubyKernel.java:1071
require at /home/user/.rvm/rubies/jruby-1.7.19/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:69
(root) at /home/user/.rvm/gems/jruby-1.7.19/gems/jruby-kafka-1.4.0-java/lib/jruby-kafka.rb:1
require at org/jruby/RubyKernel.java:1071
require at /home/user/.rvm/rubies/jruby-1.7.19/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:128
require at /home/user/.rvm/rubies/jruby-1.7.19/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:121
(root) at app.rb:4

这是在ubuntu 14.04中完成的。 当应用程序安装到具有相同设置(os,jvm,rvm,jruby版本)的其他系统时,应用程序应该正常运行。我怀疑这与jar文件本身的路径有关。 有什么建议吗?

1 个答案:

答案 0 :(得分:0)

当我完全删除了jruby并重新安装时也解决了问题。

rvm install jruby --1.9

这次安装了gem以及jar依赖项。