当前位置: 首页 > 工具软件 > Java Gems > 使用案例 >

java调用ruby_关于java调用ruby的问题。

吉玉宸
2023-12-01

java调用ruby脚本,发生错误:

LoadError: load error: jopenssl/load -- java.lang.VerifyError: class org.bouncycastle.asn1.ASN1Primitive overrides final method equals.(Ljava/lang/Object;)Z

require at org/jruby/RubyKernel.java:959

require at /opt/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:55

at /opt/jruby/lib/ruby/stdlib/openssl.rb:1

require at org/jruby/RubyKernel.java:959

require at /opt/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:55

at /opt/jruby/lib/ruby/stdlib/net/https.rb:1

require at org/jruby/RubyKernel.java:959

require at /opt/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:55

at /opt/jruby/lib/ruby/stdlib/net/https.rb:23

require at org/jruby/RubyKernel.java:959

(root) at /opt/jruby/lib/ruby/gems/shared/gems/nexpose-6.0.0/lib/nexpose.rb:1

at /opt/jruby/lib/ruby/gems/shared/gems/nexpose-6.0.0/lib/nexpose.rb:53

javax.script.ScriptException: org.jruby.embed.EvalFailedException: (LoadError) load error: jopenssl/load -- java.lang.VerifyError: class org.bouncycastle.asn1.ASN1Primitive overrides final method equals.(Ljava/lang/Object;)Z

at org.jruby.embed.jsr223.JRubyEngine.wrapException(JRubyEngine.java:104)

at org.jruby.embed.jsr223.JRubyEngine.eval(JRubyEngine.java:121)

at org.jruby.embed.jsr223.JRubyEngine.eval(JRubyEngine.java:146)

at dac.dcp.impl.collector.webservice.workers.task.nexpose.executeRuby.RubyInterface.main(RubyInterface.java:381)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

Caused by: org.jruby.embed.EvalFailedException: (LoadError) load error: jopenssl/load -- java.lang.VerifyError: class org.bouncycastle.asn1.ASN1Primitive overrides final method equals.(Ljava/lang/Object;)Z

at org.jruby.embed.internal.EmbedEvalUnitImpl.run(EmbedEvalUnitImpl.java:131)

at org.jruby.embed.jsr223.JRubyEngine.eval(JRubyEngine.java:118)

... 7 more

Caused by: org.jruby.exceptions.RaiseException: (LoadError) load error: jopenssl/load -- java.lang.VerifyError: class org.bouncycastle.asn1.ASN1Primitive overrides final method equals.(Ljava/lang/Object;)Z

at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:959)

at opt.jruby.lib.ruby.stdlib.rubygems.core_ext.kernel_require.require(/opt/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:55)

at RUBY.(/opt/jruby/lib/ruby/stdlib/openssl.rb:1)

at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:959)

at opt.jruby.lib.ruby.stdlib.rubygems.core_ext.kernel_require.require(/opt/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:55)

at RUBY.(/opt/jruby/lib/ruby/stdlib/net/https.rb:1)

at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:959)

at opt.jruby.lib.ruby.stdlib.rubygems.core_ext.kernel_require.require(/opt/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:55)

at RUBY.(/opt/jruby/lib/ruby/stdlib/net/https.rb:23)

at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:959)

at RUBY.(root)(/opt/jruby/lib/ruby/gems/shared/gems/nexpose-6.0.0/lib/nexpose.rb:1)

at RUBY.(/opt/jruby/lib/ruby/gems/shared/gems/nexpose-6.0.0/lib/nexpose.rb:53)

17/08/23 17:56:41 ERROR executeRuby.RubyInterface: org.jruby.embed.EvalFailedException: (LoadError) load error: jopenssl/load -- java.lang.VerifyError: class org.bouncycastle.asn1.ASN1Primitive overrides final method equals.(Ljava/lang/Object;)Z

源代码如下:

ScriptEngineManagermanager =newScriptEngineManager();engine=manager.getEngineByName("jruby");System.out.println(engine);try{engine.eval(newBufferedReader(newFileReader("conf/service/asset.rb")));/*invocable = (Invocable) engine;invocable.invokeFunction("getSite");*/}catch(Exceptione) {e.printStackTrace();logger.error(e.getMessage());}

ruby脚本:

class Site

def hello()

puts 'hello'

end

end

defgetSite  Site.new

end

 类似资料: