im使用以下宝石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
succefull 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文件本身的路径有关。有任何建议吗?
当我完全删除jruby时解决了问题,并通过陈述Ruby来重新安装。
rvm install jruby --1.9
这次将宝石与jar依赖关系一起安装。