[英]How to run ruby which require a ruby library(mcollective) from java using jruby
I am trying to run the following ruby script. 我正在尝试运行以下ruby脚本。
require 'rubygems'
require 'mcollective'
from following java code 从以下java代码
ScriptingContainer ruby = new ScriptingContainer(LocalVariableBehavior.PERSISTENT);
Object result = ruby.runScriptlet(PathType.ABSOLUTE,"/opt/ruby_test.rb");
But I am getting the following exception. 但是我收到以下异常。
require at org/jruby/RubyKernel.java:1027
require at jar:file:/tmp/target/dependency-jars/jruby-complete-1.7.3.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:36
(root) at /opt/ruby_test.rb:3
Exception in thread "main" org.jruby.embed.EvalFailedException: (LoadError) no such file to load -- mcollective
at org.jruby.embed.internal.EmbedEvalUnitImpl.run(EmbedEvalUnitImpl.java:133)
at org.jruby.embed.ScriptingContainer.runUnit(ScriptingContainer.java:1264)
at org.jruby.embed.ScriptingContainer.runScriptlet(ScriptingContainer.java:1309)
at mcollective.mcollective.run(mcollective.java:18)
at mcollective.mcollective.main(mcollective.java:12)
Caused by: org.jruby.exceptions.RaiseException: (LoadError) no such file to load -- mcollective
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1027)
at RUBY.require(jar:file:/tmp/target/dependency-jars/jruby-complete-1.7.3.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:36)
at RUBY.(root)(/opt/ruby_test.rb:3)
Please help me to solve this. 请帮我解决这个问题。
我通过使用rvm安装mcollective-client ruby gems解决了该问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.