我尝试使用 JRuby、Open URI 和 JRuby-OSSL 编写的非常简单的程序有问题。
我使用以下方法安装了 JRuby-OSSL gem:
gem install jruby-openssl
并下载了最新的 jruby-complete jar (1.6.7)。
我有简单的脚本 test.rb:
require 'jruby/openssl/gem_only'
require 'open-uri'
open('https://google.com')
当我像这样运行它时:
java -jar jruby-complete-1.6.7.jar test.rb
我得到:
NameError: uninitialized constant Net::HTTP::OpenSSL
const_missing at org/jruby/RubyModule.java:2642
use_ssl= at file:/Users/mislocin/.m2/repository/org/jruby/jruby-complete/1.6.7/jruby-complete-1.6.7.jar!/META-INF/jruby.home/lib/ruby/1.8/net/https.rb:124
open_http at file:/Users/mislocin/.m2/repository/org/jruby/jruby-complete/1.6.7/jruby-complete-1.6.7.jar!/META-INF/jruby.home/lib/ruby/1.8/open-uri.rb:231
buffer_open at file:/Users/mislocin/.m2/repository/org/jruby/jruby-complete/1.6.7/jruby-complete-1.6.7.jar!/META-INF/jruby.home/lib/ruby/1.8/open-uri.rb:616
open_loop at file:/Users/mislocin/.m2/repository/org/jruby/jruby-complete/1.6.7/jruby-complete-1.6.7.jar!/META-INF/jruby.home/lib/ruby/1.8/open-uri.rb:164
catch at org/jruby/RubyKernel.java:1183
open_loop at file:/Users/mislocin/.m2/repository/org/jruby/jruby-complete/1.6.7/jruby-complete-1.6.7.jar!/META-INF/jruby.home/lib/ruby/1.8/open-uri.rb:162
open_uri at file:/Users/mislocin/.m2/repository/org/jruby/jruby-complete/1.6.7/jruby-complete-1.6.7.jar!/META-INF/jruby.home/lib/ruby/1.8/open-uri.rb:132
open at file:/Users/mislocin/.m2/repository/org/jruby/jruby-complete/1.6.7/jruby-complete-1.6.7.jar!/META-INF/jruby.home/lib/ruby/1.8/open-uri.rb:518
open at file:/Users/mislocin/.m2/repository/org/jruby/jruby-complete/1.6.7/jruby-complete-1.6.7.jar!/META-INF/jruby.home/lib/ruby/1.8/open-uri.rb:30
(root) at test.rb:4
我很确定我错过了一些细节,任何帮助表示赞赏。