JOpenSSL gem inside JRuby Complete

We had faced quite a lot of issues trying to embed JOpenSSL inside jruby-complete.jar.

We used to get an error “Uninitialized constant OpenSSL::Digest::OPENSSL_VERSION_NUMBER” with the following stack trace :

NameError: uninitialized constant OpenSSL::Digest::OPENSSL_VERSION_NUMBER
from file:/home/msuser1/jruby-complete-1.3.1.jar!/META-INF/jruby.home/lib/ruby/gems/1.8/gems/jruby-openssl-0.6/lib/openssl/cipher.rb:28:in `const_missing’
from file:/home/msuser1/jruby-complete-1.3.1.jar!/META-INF/jruby.home/lib/ruby/gems/1.8/gems/jruby-openssl-0.6/lib/openssl/digest.rb:23
from file:/home/msuser1/jruby-complete-1.3.1.jar!/META-INF/jruby.home/lib/ruby/gems/1.8/gems/jruby-openssl-0.6/lib/openssl/digest.rb:31:in `require’
from file:/home/msuser1/jruby-complete-1.3.1.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’
from file:/home/msuser1/jruby-complete-1.3.1.jar!/META-INF/jruby.home/lib/ruby/gems/1.8/gems/jruby-openssl-0.6/lib/openssl.rb:24
from file:/home/msuser1/jruby-complete-1.3.1.jar!/META-INF/jruby.home/lib/ruby/gems/1.8/gems/jruby-openssl-0.6/lib/openssl.rb:31:in `require’
from file:/home/msuser1/jruby-complete-1.3.1.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’

You can find Charles’ explanation here

What we did is the following :

1. Add the Jruby-openssl gem inside the jruby-complete.jar bundle like adding any other gems(rspec, rake etc.)
2. Extract the JRuby Complete Jar in a fresh folder
3. In addition to this, extract the contents of jopenssl.jar directly under the root folder. (jopenssl.jar is located inside the lib folder of the jruby-openssl gem).
4. Re-create the jruby-complete.jar from this exploded folder.

Thats about it, you are all set to use openssl inside jruby without any issue.

Please note, at the time of writing this post, I was using JRuby 1.3.1 and Jopenssl 0.6.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s