JRuby

uninitialized constant OpenSSL::X509::Store

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: JRuby 1.0.3
  • Fix Version/s: JRuby 1.1RC2
  • Component/s: OpenSSL
  • Labels:
    None
  • Environment:
    Macintosh OS 10.5.1
  • Number of attachments :
    0

Description

Fails trying to load constant when making HTTPS request via SOAP4R.

/opt/jruby/jruby-1.0.3/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:263:in `load_missing_constant'
/opt/jruby/jruby-1.0.3/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:453:in `const_missing'
/opt/jruby/jruby-1.0.3/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:152:in `initialize'
/opt/jruby/jruby-1.0.3/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:1744:in `new'
/opt/jruby/jruby-1.0.3/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:1744:in `initialize'
/opt/jruby/jruby-1.0.3/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/wsdl/xmlSchema/importer.rb:66:in `new'
/opt/jruby/jruby-1.0.3/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/wsdl/xmlSchema/importer.rb:66:in `fetch'
/opt/jruby/jruby-1.0.3/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/wsdl/xmlSchema/importer.rb:36:in `import'
/opt/jruby/jruby-1.0.3/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/wsdl/importer.rb:18:in `import'
/opt/jruby/jruby-1.0.3/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/wsdlDriver.rb:146:in `import'
/opt/jruby/jruby-1.0.3/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/wsdlDriver.rb:32:in `initialize'
app/controllers/login_controller.rb:19:in `new'
app/controllers/login_controller.rb:19:in `login'

Activity

Hide
Raphael Valyi added a comment -

I suspect I'm getting the same bug but using the ruby-openid Rails plugin instead.
This is a regression because it used to work one or two months ago. I've the same code passing with MRI Ruby. Also this is with JRuby head and Rails head.

My own stack trace is:

uninitialized constant OpenID::Store

vendor/rails/activesupport/lib/active_support/dependencies.rb:263:in `load_missing_constant'
vendor/rails/activesupport/lib/active_support/dependencies.rb:253:in `const_missing'
vendor/plugins/open_id_authentication/lib/open_id_authentication/db_store.rb:2:in `const_missing'
vendor/rails/activesupport/lib/active_support/dependencies.rb:203
vendor/rails/activesupport/lib/active_support/dependencies.rb:203:in `load'
vendor/rails/activesupport/lib/active_support/dependencies.rb:203:in `load_file'
vendor/rails/activesupport/lib/active_support/dependencies.rb:202:in `new_constants_in'
vendor/rails/activesupport/lib/active_support/dependencies.rb:318:in `load_file'
vendor/rails/activesupport/lib/active_support/dependencies.rb:202:in `require_or_load'
vendor/rails/activesupport/lib/active_support/dependencies.rb:248:in `load_missing_constant'
vendor/rails/activesupport/lib/active_support/dependencies.rb:453:in `const_missing'
vendor/plugins/open_id_authentication/lib/open_id_authentication.rb:125:in `open_id_store'
vendor/plugins/open_id_authentication/lib/open_id_authentication.rb:120:in `open_id_consumer'
vendor/plugins/open_id_authentication/lib/open_id_authentication.rb:93:in `begin_open_id_authentication'
vendor/plugins/open_id_authentication/lib/open_id_authentication.rb:93:in `timeout_protection_from_identity_server'
vendor/plugins/open_id_authentication/lib/open_id_authentication.rb:93:in `begin_open_id_authentication'
vendor/plugins/open_id_authentication/lib/open_id_authentication.rb:93:in `authenticate_with_open_id'
app/controllers/auth_controller.rb:526:in `open_id_authentication'
app/controllers/auth_controller.rb:526:in `openid_login'

I'll try to find the regression possibly during the weekend. Hope it's the same bug.

Raphaël Valyi.

Show
Raphael Valyi added a comment - I suspect I'm getting the same bug but using the ruby-openid Rails plugin instead. This is a regression because it used to work one or two months ago. I've the same code passing with MRI Ruby. Also this is with JRuby head and Rails head. My own stack trace is: uninitialized constant OpenID::Store vendor/rails/activesupport/lib/active_support/dependencies.rb:263:in `load_missing_constant' vendor/rails/activesupport/lib/active_support/dependencies.rb:253:in `const_missing' vendor/plugins/open_id_authentication/lib/open_id_authentication/db_store.rb:2:in `const_missing' vendor/rails/activesupport/lib/active_support/dependencies.rb:203 vendor/rails/activesupport/lib/active_support/dependencies.rb:203:in `load' vendor/rails/activesupport/lib/active_support/dependencies.rb:203:in `load_file' vendor/rails/activesupport/lib/active_support/dependencies.rb:202:in `new_constants_in' vendor/rails/activesupport/lib/active_support/dependencies.rb:318:in `load_file' vendor/rails/activesupport/lib/active_support/dependencies.rb:202:in `require_or_load' vendor/rails/activesupport/lib/active_support/dependencies.rb:248:in `load_missing_constant' vendor/rails/activesupport/lib/active_support/dependencies.rb:453:in `const_missing' vendor/plugins/open_id_authentication/lib/open_id_authentication.rb:125:in `open_id_store' vendor/plugins/open_id_authentication/lib/open_id_authentication.rb:120:in `open_id_consumer' vendor/plugins/open_id_authentication/lib/open_id_authentication.rb:93:in `begin_open_id_authentication' vendor/plugins/open_id_authentication/lib/open_id_authentication.rb:93:in `timeout_protection_from_identity_server' vendor/plugins/open_id_authentication/lib/open_id_authentication.rb:93:in `begin_open_id_authentication' vendor/plugins/open_id_authentication/lib/open_id_authentication.rb:93:in `authenticate_with_open_id' app/controllers/auth_controller.rb:526:in `open_id_authentication' app/controllers/auth_controller.rb:526:in `openid_login' I'll try to find the regression possibly during the weekend. Hope it's the same bug. Raphaël Valyi.
Hide
Raphael Valyi added a comment -

OK,

sorry, wrong issue on my side: the ruby-openid bug I had was related to ruby-openid 2.0.2 (see http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/3c17f6b52384bec0/a9c9fba6e5dcfafe?lnk=raot ), not to jruby (I thought I had a regression because my MRI ruby was running the old ruby-openid 1.1.4 gem). So no general issue with module inclusion as I though. Still I don't know what is going on with your soap4r, good luck for that one. Regards.

Show
Raphael Valyi added a comment - OK, sorry, wrong issue on my side: the ruby-openid bug I had was related to ruby-openid 2.0.2 (see http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/3c17f6b52384bec0/a9c9fba6e5dcfafe?lnk=raot ), not to jruby (I thought I had a regression because my MRI ruby was running the old ruby-openid 1.1.4 gem). So no general issue with module inclusion as I though. Still I don't know what is going on with your soap4r, good luck for that one. Regards.
Hide
Ola Bini added a comment -

I can reproduce this locally, after gem installing httpclient:

require 'rubygems'
require 'httpclient'

p HTTPClient.new

Next step is to see if this is a problem with trunk too.

Show
Ola Bini added a comment - I can reproduce this locally, after gem installing httpclient:
require 'rubygems'
require 'httpclient'

p HTTPClient.new
Next step is to see if this is a problem with trunk too.
Hide
Ola Bini added a comment -

Trunk also fails for this, but in a different way:

WARNING: un-implemented method called PKCS7#read_smime
/Users/olabini/workspace/jruby/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:390:in `load_cacerts': undefined method `data' for nil:NilClass (NoMethodError)
        from /Users/olabini/workspace/jruby/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:386:in `initialize'
        from /Users/olabini/workspace/jruby/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:1744:in `new'
        from /Users/olabini/workspace/jruby/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:1744:in `initialize'
        from ../jruby-1.0/testo.rb:4:in `new'
        from ../jruby-1.0/testo.rb:4:in `new'

This is more benign though - since the PKCS7 method is not implemented. It needs to be implemented to make httpclient work correctly.

Show
Ola Bini added a comment - Trunk also fails for this, but in a different way:
WARNING: un-implemented method called PKCS7#read_smime
/Users/olabini/workspace/jruby/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:390:in `load_cacerts': undefined method `data' for nil:NilClass (NoMethodError)
        from /Users/olabini/workspace/jruby/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:386:in `initialize'
        from /Users/olabini/workspace/jruby/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:1744:in `new'
        from /Users/olabini/workspace/jruby/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:1744:in `initialize'
        from ../jruby-1.0/testo.rb:4:in `new'
        from ../jruby-1.0/testo.rb:4:in `new'
This is more benign though - since the PKCS7 method is not implemented. It needs to be implemented to make httpclient work correctly.
Hide
Ola Bini added a comment -

Switching this to critical. This is a problem with the new loading mechanism for OpenSSL and it will have several bad interactions, it seems.

The problem is this: if openssl is NOT installed, what happens is this:

If you require a gem that needs openssl, RubyGems tries to load openssl, including trying to load the real gem. Loading the real gem fails and throws an exception. This exception is catched (but not catching it doesn't make a difference). The state we are in right now means that loading the gem has already failed, but openssl has returned correctly, and been added to the "loaded" list, so the next time someone tries to load it, the loading works correctly. So httpclient thinks that openssl is available and starts referring to stuff inside it, like the X509::Store. Of course, this fails. Httpclient CAN load without openssl, but the broken way the autoloads are done this will never happen - instead it will error out.

This is almost a blocker, and something we need to fix before 1.0.4 and the 1.1. Note, this affects trunk too.

Show
Ola Bini added a comment - Switching this to critical. This is a problem with the new loading mechanism for OpenSSL and it will have several bad interactions, it seems. The problem is this: if openssl is NOT installed, what happens is this: If you require a gem that needs openssl, RubyGems tries to load openssl, including trying to load the real gem. Loading the real gem fails and throws an exception. This exception is catched (but not catching it doesn't make a difference). The state we are in right now means that loading the gem has already failed, but openssl has returned correctly, and been added to the "loaded" list, so the next time someone tries to load it, the loading works correctly. So httpclient thinks that openssl is available and starts referring to stuff inside it, like the X509::Store. Of course, this fails. Httpclient CAN load without openssl, but the broken way the autoloads are done this will never happen - instead it will error out. This is almost a blocker, and something we need to fix before 1.0.4 and the 1.1. Note, this affects trunk too.
Hide
Ola Bini added a comment -

Nick, you have any wonderful ideas on how to solve this?

Show
Ola Bini added a comment - Nick, you have any wonderful ideas on how to solve this?
Hide
Nick Sieger added a comment -

Well, the problem is really one of bad messaging. It's appropriate for this to fail since the openssl gem is not installed, but what's probably not appropriate is for it to fail simply with an "uninitialized constant" error.

The workaround is simple, just install the jruby-openssl gem. I'll see if I can get the error messaging to fail, or perhaps dump a warning to the screen when we are unable to load the openssl gem.

Show
Nick Sieger added a comment - Well, the problem is really one of bad messaging. It's appropriate for this to fail since the openssl gem is not installed, but what's probably not appropriate is for it to fail simply with an "uninitialized constant" error. The workaround is simple, just install the jruby-openssl gem. I'll see if I can get the error messaging to fail, or perhaps dump a warning to the screen when we are unable to load the openssl gem.
Hide
Ola Bini added a comment -

I don't agree with the resolving of this. It's a totally unacceptable way to blow up.

Also, realize that these libraries DOES NOT require openssl to be available. They will work ANYWAY. But not with the current implementation of OpenSSL loading. That is the real problem - the messaging is the least part of it. People shouldn't have to install openssl to use libraries that doesn't actually need it.

Show
Ola Bini added a comment - I don't agree with the resolving of this. It's a totally unacceptable way to blow up. Also, realize that these libraries DOES NOT require openssl to be available. They will work ANYWAY. But not with the current implementation of OpenSSL loading. That is the real problem - the messaging is the least part of it. People shouldn't have to install openssl to use libraries that doesn't actually need it.
Hide
Nick Sieger added a comment -

One more comment on this – the original hack was done mostly to accomodate Rails 2.0, and acknowledges that other libraries will not have nearly as much use. With that in mind, I don't think this is a blocker, if we still have Rails 2.0 compatibility out of the box while soap4r/httpclient perhaps behave slightly badly as a result.

One more compromise would be to have one last JRuby-specific library that could be required that would set a constant such that if the openssl gem was not present, "require 'openssl'" would raise a proper LoadError rather than the current behavior.

# no jruby-openssl gem installed
require 'jruby/no_builtin_openssl'
require 'openssl' # => LoadError
Show
Nick Sieger added a comment - One more comment on this – the original hack was done mostly to accomodate Rails 2.0, and acknowledges that other libraries will not have nearly as much use. With that in mind, I don't think this is a blocker, if we still have Rails 2.0 compatibility out of the box while soap4r/httpclient perhaps behave slightly badly as a result. One more compromise would be to have one last JRuby-specific library that could be required that would set a constant such that if the openssl gem was not present, "require 'openssl'" would raise a proper LoadError rather than the current behavior.
# no jruby-openssl gem installed
require 'jruby/no_builtin_openssl'
require 'openssl' # => LoadError
Hide
Charles Oliver Nutter added a comment -

Punting to post RC...not a blocker or showstopper.

Show
Charles Oliver Nutter added a comment - Punting to post RC...not a blocker or showstopper.
Hide
David M. Holmes added a comment -

As for the workaround, I do have the jruby-openssl-01 gem installed. Same error. Anything else that could be missing?

Show
David M. Holmes added a comment - As for the workaround, I do have the jruby-openssl-01 gem installed. Same error. Anything else that could be missing?
Hide
Charles Oliver Nutter added a comment -

David: so even with the gem installed you're still seeing the problem? Could you try forcing the gem to load, using "require 'rubygems'; gem 'jruby-openssl'" before all other code?

Show
Charles Oliver Nutter added a comment - David: so even with the gem installed you're still seeing the problem? Could you try forcing the gem to load, using "require 'rubygems'; gem 'jruby-openssl'" before all other code?
Hide
David M. Holmes added a comment -

Charles, I moved to Net::HTTP and crafting the SOAP call myself instead of SOAP4R. So I'm not sure if this issue is still in 1.1 RC 1 or not.

Show
David M. Holmes added a comment - Charles, I moved to Net::HTTP and crafting the SOAP call myself instead of SOAP4R. So I'm not sure if this issue is still in 1.1 RC 1 or not.
Hide
Eric Kramer added a comment -

Please don't close this issue, as I to am attempting to use SOAP4R and having this same problem. If there's anything I can do to help troubleshoot, please let me know. I'm on JRUBY 1.1 RC1. Here are my current gem versions:

actionmailer (1.3.6)
actionpack (1.13.6)
actionwebservice (1.2.6)
activerecord (1.15.6)
activerecord-jdbc-adapter (0.7.1)
activerecord-jdbcmysql-adapter (0.7.1)
activesupport (1.4.4)
crypt (1.1.4)
faker (0.3.0)
httpclient (2.1.2)
jdbc-mysql (5.0.4)
jruby-openssl (0.1.1)
log4r (1.0.5)
openwferu-scheduler (0.9.16.1404)
rails (1.2.6)
rake (0.8.1)
rspec (1.1.1)
soap4r (1.5.8)
sources (0.0.1)

Show
Eric Kramer added a comment - Please don't close this issue, as I to am attempting to use SOAP4R and having this same problem. If there's anything I can do to help troubleshoot, please let me know. I'm on JRUBY 1.1 RC1. Here are my current gem versions: actionmailer (1.3.6) actionpack (1.13.6) actionwebservice (1.2.6) activerecord (1.15.6) activerecord-jdbc-adapter (0.7.1) activerecord-jdbcmysql-adapter (0.7.1) activesupport (1.4.4) crypt (1.1.4) faker (0.3.0) httpclient (2.1.2) jdbc-mysql (5.0.4) jruby-openssl (0.1.1) log4r (1.0.5) openwferu-scheduler (0.9.16.1404) rails (1.2.6) rake (0.8.1) rspec (1.1.1) soap4r (1.5.8) sources (0.0.1)
Hide
Eric Kramer added a comment -

In the FWIW category, my code runs fine under my Windows install of JRuby (which is using RubyGems 0.9.4) but not under my Ubuntu Linux install of JRuby (which is using RubyGems 1.0.1).

Show
Eric Kramer added a comment - In the FWIW category, my code runs fine under my Windows install of JRuby (which is using RubyGems 0.9.4) but not under my Ubuntu Linux install of JRuby (which is using RubyGems 1.0.1).
Hide
Eric Kramer added a comment -

More data that supports your thinking...

Under Windows and RubyGems 0.9.4:

irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'openssl'
LoadError: no such file to load – openssl
from C:/third-party/jruby-1.1b1/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from (irb):1:in `binding'

Under Linux and RubyGems 1.0.1:

irb(main):002:0> require 'rubygems'
=> true
irb(main):003:0> require 'openssl'
=> true
irb(main):004:0> require 'openssl'
=> false
irb(main):005:0> require 'openssl'
=> false

Show
Eric Kramer added a comment - More data that supports your thinking... Under Windows and RubyGems 0.9.4: irb(main):001:0> require 'rubygems' => true irb(main):002:0> require 'openssl' LoadError: no such file to load – openssl from C:/third-party/jruby-1.1b1/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from (irb):1:in `binding' Under Linux and RubyGems 1.0.1: irb(main):002:0> require 'rubygems' => true irb(main):003:0> require 'openssl' => true irb(main):004:0> require 'openssl' => false irb(main):005:0> require 'openssl' => false
Hide
Eric Kramer added a comment -

Ah, a workaround... PLEASE do let me know if there's a better way to do this.

Adding this vile bit of code to my environment.rb file makes SOAP4R happy again:

  1. Added to work around SOAP4R design flaw re: when to (not to) use OpenSSL
  2. See: http://jira.codehaus.org/browse/JRUBY-1808
    module Kernel
    def require_hack(filename)
    if filename == 'openssl'
    raise LoadError, 'no such file to load – openssl'
    end
    orig_require(filename)
    end
    alias_method :orig_require, :require
    alias_method :require, :require_hack
    end
Show
Eric Kramer added a comment - Ah, a workaround... PLEASE do let me know if there's a better way to do this. Adding this vile bit of code to my environment.rb file makes SOAP4R happy again:
  1. Added to work around SOAP4R design flaw re: when to (not to) use OpenSSL
  2. See: http://jira.codehaus.org/browse/JRUBY-1808 module Kernel def require_hack(filename) if filename == 'openssl' raise LoadError, 'no such file to load – openssl' end orig_require(filename) end alias_method :orig_require, :require alias_method :require, :require_hack end
Hide
Nick Sieger added a comment -

Eric, would the following appeasement be more appropriate for you?

require 'jruby/openssl/gem_only'
require 'openssl' # => LoadError

Thus, requiring 'jruby/openssl/gem_only' early on in your application should allow you to use soap4r without the gem installed.

For example:

$ jruby -S irb
irb(main):001:0> require 'openssl'
=> true
irb(main):002:0> OpenSSL::X509::Store
Gem::LoadError: Could not find RubyGem jruby-openssl (>= 0)

        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/rubygems.rb:379:in `report_activate_error'
        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/rubygems.rb:311:in `activate'
        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/rubygems.rb:65:in `active_gem_with_options'
        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/rubygems.rb:50:in `gem'
        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/jruby/openssl/gem.rb:2
        from (irb):3:in `initialize'
irb(main):003:0>
$ jruby -S irb
irb(main):001:0> require 'jruby/openssl/gem_only'
=> true
irb(main):002:0> require 'openssl'
Gem::LoadError: Could not find RubyGem jruby-openssl (>= 0)

        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/rubygems.rb:379:in `report_activate_error'
        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/rubygems.rb:311:in `activate'
        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/rubygems.rb:65:in `active_gem_with_options'
        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/rubygems.rb:50:in `gem'
        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/jruby/openssl/gem.rb:2
        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/jruby/openssl/stub.rb:8:in `require'
        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/jruby/openssl/stub.rb:8
        from (irb):3:in `require'
        from (irb):3:in `initialize'
$ jruby -S gem install jruby-openssl
Successfully installed jruby-openssl-0.1.1
1 gem installed
Installing ri documentation for jruby-openssl-0.1.1...
Installing RDoc documentation for jruby-openssl-0.1.1...
$ jruby -S irb
irb(main):001:0> require 'openssl'
=> true
irb(main):002:0> OpenSSL::X509::Store
=> OpenSSL::X509::Store
irb(main):003:0>
$ jruby -S irb
irb(main):001:0> require 'jruby/openssl/gem_only'
=> true
irb(main):002:0> require 'openssl'
=> true
irb(main):003:0> OpenSSL::X509::Store
=> OpenSSL::X509::Store
Show
Nick Sieger added a comment - Eric, would the following appeasement be more appropriate for you?
require 'jruby/openssl/gem_only'
require 'openssl' # => LoadError
Thus, requiring 'jruby/openssl/gem_only' early on in your application should allow you to use soap4r without the gem installed. For example:
$ jruby -S irb
irb(main):001:0> require 'openssl'
=> true
irb(main):002:0> OpenSSL::X509::Store
Gem::LoadError: Could not find RubyGem jruby-openssl (>= 0)

        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/rubygems.rb:379:in `report_activate_error'
        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/rubygems.rb:311:in `activate'
        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/rubygems.rb:65:in `active_gem_with_options'
        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/rubygems.rb:50:in `gem'
        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/jruby/openssl/gem.rb:2
        from (irb):3:in `initialize'
irb(main):003:0>
$ jruby -S irb
irb(main):001:0> require 'jruby/openssl/gem_only'
=> true
irb(main):002:0> require 'openssl'
Gem::LoadError: Could not find RubyGem jruby-openssl (>= 0)

        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/rubygems.rb:379:in `report_activate_error'
        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/rubygems.rb:311:in `activate'
        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/rubygems.rb:65:in `active_gem_with_options'
        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/rubygems.rb:50:in `gem'
        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/jruby/openssl/gem.rb:2
        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/jruby/openssl/stub.rb:8:in `require'
        from /Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/jruby/openssl/stub.rb:8
        from (irb):3:in `require'
        from (irb):3:in `initialize'
$ jruby -S gem install jruby-openssl
Successfully installed jruby-openssl-0.1.1
1 gem installed
Installing ri documentation for jruby-openssl-0.1.1...
Installing RDoc documentation for jruby-openssl-0.1.1...
$ jruby -S irb
irb(main):001:0> require 'openssl'
=> true
irb(main):002:0> OpenSSL::X509::Store
=> OpenSSL::X509::Store
irb(main):003:0>
$ jruby -S irb
irb(main):001:0> require 'jruby/openssl/gem_only'
=> true
irb(main):002:0> require 'openssl'
=> true
irb(main):003:0> OpenSSL::X509::Store
=> OpenSSL::X509::Store
Hide
Nick Sieger added a comment -

Situation is hopefully improved with 5693. Should this be backported to 1.0.4?

Show
Nick Sieger added a comment - Situation is hopefully improved with 5693. Should this be backported to 1.0.4?
Hide
Matthew Kanwisher added a comment -

Its still failing on Mac OSX leopard, I have JRuby 1.1RC2. I tried changed the require line in httpclient.rb to require 'jruby/openssl/gem_only' and it doesn't help. Disabling ssl in httpclient.rb seems to work tho ;/

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.data

RAILS_ROOT: /code/rails/test
Application Trace | Framework Trace | Full Trace

/java/jruby-1.1RC2/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:390:in `load_cacerts'
/java/jruby-1.1RC2/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:386:in `initialize'
/java/jruby-1.1RC2/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:1744:in `new'
/java/jruby-1.1RC2/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:1744:in `initialize'
/java/jruby-1.1RC2/lib/ruby/1.8/soap/streamHandler.rb:145:in `new'
/java/jruby-1.1RC2/lib/ruby/1.8/soap/streamHandler.rb:145:in `initialize'
/java/jruby-1.1RC2/lib/ruby/1.8/soap/streamHandler.rb:140:in `new'
/java/jruby-1.1RC2/lib/ruby/1.8/soap/streamHandler.rb:140:in `create'
/java/jruby-1.1RC2/lib/ruby/1.8/soap/rpc/proxy.rb:213:in `initialize_streamhandler'
/java/jruby-1.1RC2/lib/ruby/1.8/soap/rpc/proxy.rb:51:in `initialize'
/java/jruby-1.1RC2/lib/ruby/1.8/soap/rpc/driver.rb:116:in `new'
/java/jruby-1.1RC2/lib/ruby/1.8/soap/rpc/driver.rb:116:in `initialize'
lib/anystream/defaultDriver.rb:301:in `initialize'
app/controllers/encode_video_controller.rb:10:in `new'
app/controllers/encode_video_controller.rb:10:in `index'

Show
Matthew Kanwisher added a comment - Its still failing on Mac OSX leopard, I have JRuby 1.1RC2. I tried changed the require line in httpclient.rb to require 'jruby/openssl/gem_only' and it doesn't help. Disabling ssl in httpclient.rb seems to work tho ;/ You have a nil object when you didn't expect it! The error occurred while evaluating nil.data RAILS_ROOT: /code/rails/test Application Trace | Framework Trace | Full Trace /java/jruby-1.1RC2/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:390:in `load_cacerts' /java/jruby-1.1RC2/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:386:in `initialize' /java/jruby-1.1RC2/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:1744:in `new' /java/jruby-1.1RC2/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:1744:in `initialize' /java/jruby-1.1RC2/lib/ruby/1.8/soap/streamHandler.rb:145:in `new' /java/jruby-1.1RC2/lib/ruby/1.8/soap/streamHandler.rb:145:in `initialize' /java/jruby-1.1RC2/lib/ruby/1.8/soap/streamHandler.rb:140:in `new' /java/jruby-1.1RC2/lib/ruby/1.8/soap/streamHandler.rb:140:in `create' /java/jruby-1.1RC2/lib/ruby/1.8/soap/rpc/proxy.rb:213:in `initialize_streamhandler' /java/jruby-1.1RC2/lib/ruby/1.8/soap/rpc/proxy.rb:51:in `initialize' /java/jruby-1.1RC2/lib/ruby/1.8/soap/rpc/driver.rb:116:in `new' /java/jruby-1.1RC2/lib/ruby/1.8/soap/rpc/driver.rb:116:in `initialize' lib/anystream/defaultDriver.rb:301:in `initialize' app/controllers/encode_video_controller.rb:10:in `new' app/controllers/encode_video_controller.rb:10:in `index'
Hide
Nick Sieger added a comment -

Matthew:

You should leave httpclient alone; what happens if you revert httpclient (or install a pristine copy) and put the "require 'jruby/openssl/gem_only'" line in your config/environment.rb?

Show
Nick Sieger added a comment - Matthew: You should leave httpclient alone; what happens if you revert httpclient (or install a pristine copy) and put the "require 'jruby/openssl/gem_only'" line in your config/environment.rb?
Hide
Matthew Kanwisher added a comment -

1) Pristine httpclient (Check)
2) "require 'jruby/openssl/gem_only'" line in your config/environment.rb(Check)

Still Failed, same error.
However it always works if I run my soap client in a command line Jruby, it only fails while running in rails. It seems to be the same PKCS7 error Ola was having.

Show
Matthew Kanwisher added a comment - 1) Pristine httpclient (Check) 2) "require 'jruby/openssl/gem_only'" line in your config/environment.rb(Check) Still Failed, same error. However it always works if I run my soap client in a command line Jruby, it only fails while running in rails. It seems to be the same PKCS7 error Ola was having.
Hide
Nick Sieger added a comment -

Matthew: it might be the case that your require statement is not getting pulled in early enough. If you're using Rails 2, try putting the require in a file called 'config/preinitializer.rb', or otherwise make sure that the require is done early in the environment.rb file. Does either of those suggestions help?

Show
Nick Sieger added a comment - Matthew: it might be the case that your require statement is not getting pulled in early enough. If you're using Rails 2, try putting the require in a file called 'config/preinitializer.rb', or otherwise make sure that the require is done early in the environment.rb file. Does either of those suggestions help?
Hide
Matthew Kanwisher added a comment -

Wheh after quite a bit of digging, I'm a bit confused, looking at the source to the PKCS7 implementation it always returns a nil object form the method read_smime, so it would seem if you ever require 'openssl' it would go into this code path in httpclient.rb and fail. Only thing I can see around this problem at the moment is to make read_smime return a fake stub object with all the proper methods. If this seems reasonable I can make a patch for this.

I can reproduce this problem with a single ruby file using these require lines at the top.

require 'rubygems'
require 'jruby/openssl/gem_only'
require 'openssl'
require 'defaultDriver.rb'

Implementation file I'm looking at:
http://jruby-extras.rubyforge.org/svn/trunk/jopenssl/src/java/org/jruby/ext/openssl/PKCS7.java

My Stacktrace:
WARNING: un-implemented method called PKCS7#read_smime
/java/jruby-1.1RC2/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:390:in `load_cacerts': undefined method `data' for nil:NilClass (NoMethodError)
from /java/jruby-1.1RC2/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:386:in `initialize'
from /java/jruby-1.1RC2/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:1744:in `new'
from /java/jruby-1.1RC2/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:1744:in `initialize'
from /java/jruby-1.1RC2/lib/ruby/1.8/soap/streamHandler.rb:145:in `new'
from /java/jruby-1.1RC2/lib/ruby/1.8/soap/streamHandler.rb:145:in `initialize'
from /java/jruby-1.1RC2/lib/ruby/1.8/soap/streamHandler.rb:140:in `new'
from /java/jruby-1.1RC2/lib/ruby/1.8/soap/streamHandler.rb:140:in `create'
from /java/jruby-1.1RC2/lib/ruby/1.8/soap/rpc/proxy.rb:213:in `initialize_streamhandler'
from /java/jruby-1.1RC2/lib/ruby/1.8/soap/rpc/proxy.rb:51:in `initialize'
from /java/jruby-1.1RC2/lib/ruby/1.8/soap/rpc/driver.rb:116:in `new'
from /java/jruby-1.1RC2/lib/ruby/1.8/soap/rpc/driver.rb:116:in `initialize'
from /code/testsoap/./defaultDriver.rb:301:in `initialize'

Show
Matthew Kanwisher added a comment - Wheh after quite a bit of digging, I'm a bit confused, looking at the source to the PKCS7 implementation it always returns a nil object form the method read_smime, so it would seem if you ever require 'openssl' it would go into this code path in httpclient.rb and fail. Only thing I can see around this problem at the moment is to make read_smime return a fake stub object with all the proper methods. If this seems reasonable I can make a patch for this. I can reproduce this problem with a single ruby file using these require lines at the top. require 'rubygems' require 'jruby/openssl/gem_only' require 'openssl' require 'defaultDriver.rb' Implementation file I'm looking at: http://jruby-extras.rubyforge.org/svn/trunk/jopenssl/src/java/org/jruby/ext/openssl/PKCS7.java My Stacktrace: WARNING: un-implemented method called PKCS7#read_smime /java/jruby-1.1RC2/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:390:in `load_cacerts': undefined method `data' for nil:NilClass (NoMethodError) from /java/jruby-1.1RC2/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:386:in `initialize' from /java/jruby-1.1RC2/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:1744:in `new' from /java/jruby-1.1RC2/lib/ruby/gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:1744:in `initialize' from /java/jruby-1.1RC2/lib/ruby/1.8/soap/streamHandler.rb:145:in `new' from /java/jruby-1.1RC2/lib/ruby/1.8/soap/streamHandler.rb:145:in `initialize' from /java/jruby-1.1RC2/lib/ruby/1.8/soap/streamHandler.rb:140:in `new' from /java/jruby-1.1RC2/lib/ruby/1.8/soap/streamHandler.rb:140:in `create' from /java/jruby-1.1RC2/lib/ruby/1.8/soap/rpc/proxy.rb:213:in `initialize_streamhandler' from /java/jruby-1.1RC2/lib/ruby/1.8/soap/rpc/proxy.rb:51:in `initialize' from /java/jruby-1.1RC2/lib/ruby/1.8/soap/rpc/driver.rb:116:in `new' from /java/jruby-1.1RC2/lib/ruby/1.8/soap/rpc/driver.rb:116:in `initialize' from /code/testsoap/./defaultDriver.rb:301:in `initialize'
Hide
Juan Tarquino added a comment -

I get the same error as Matthew. I can confirm that adding the require 'jruby/openssl/gem_only' line to config/preinitializer.rb does not solve the problem with the nil.data . I also can confirm that, as Matthew said, setting SSLEnabled = false in the httpclient.rb files does make the problem disappear.

I am running the Rails app from my Windows machine using Jruby 1.1. My rails application uses the soap4r to connect to a JasperServer on a Linux machine.

I guess the bug is still there in 1.1 ...

Show
Juan Tarquino added a comment - I get the same error as Matthew. I can confirm that adding the require 'jruby/openssl/gem_only' line to config/preinitializer.rb does not solve the problem with the nil.data . I also can confirm that, as Matthew said, setting SSLEnabled = false in the httpclient.rb files does make the problem disappear. I am running the Rails app from my Windows machine using Jruby 1.1. My rails application uses the soap4r to connect to a JasperServer on a Linux machine. I guess the bug is still there in 1.1 ...
Hide
Nick Sieger added a comment -

Seems that Matthew and Juan's problem has been duplicated and reported as JRUBY-2151, in case anyone is reading this.

Show
Nick Sieger added a comment - Seems that Matthew and Juan's problem has been duplicated and reported as JRUBY-2151, in case anyone is reading this.

People

Vote (0)
Watch (4)

Dates

  • Created:
    Updated:
    Resolved: