JRuby

Rails 2.0.1 not working with trunk

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: JRuby 1.0.2, JRuby 1.1b1
  • Fix Version/s: JRuby 1.0.3, JRuby 1.1RC1
  • Component/s: OpenSSL
  • Labels:
    None
  • Environment:
    WINDOZE (W2k; Java 5 (1.5.0_06)) Fresh checkout with both JRuby branch and JRuby trunk
  • Number of attachments :
    0

Description

I just tried out Rails 2.0.1. Perhaps this is a non-issue and has been fixed in a non-released version of openssl, but I thought I would report it in case it slipped through the cracks.

./bin/jruby -S rails heh
uninitialized constant Digest::SHA2
[Fuebo /opt/workspace/jruby_trunk]$ ./bin/jruby -S gem install jruby-openssl -y --no-ri --no-rdoc
Successfully installed jruby-openssl-0.0.4
[Fuebo /opt/workspace/jruby_trunk]$ ./bin/jruby -S rails heh
private method `rand' called for OpenSSL::BN:Class

Activity

Hide
Vladimir Sizikov added a comment -

Interesting. I had no problems with Rails 2.0.1. First time I tried to start the server, it was complaining about the need for jruby-openssl gem, I instaled it , and after that everything was fine (well, there was a bug about TCPSocket not accepting nil, but that's different story and is already fixed in the trunk).

Show
Vladimir Sizikov added a comment - Interesting. I had no problems with Rails 2.0.1. First time I tried to start the server, it was complaining about the need for jruby-openssl gem, I instaled it , and after that everything was fine (well, there was a bug about TCPSocket not accepting nil, but that's different story and is already fixed in the trunk).
Hide
Thomas E Enebo added a comment -

This does not happen on MacOS.

Show
Thomas E Enebo added a comment - This does not happen on MacOS.
Hide
Thomas E Enebo added a comment -

I just tried this with a release candidate of jruby 1.0.3 and I am getting same exact behavior as in description. Is anyone else seeing this? I updated environment to be a little more specific with my environment in case it that sheds any light on this.

Show
Thomas E Enebo added a comment - I just tried this with a release candidate of jruby 1.0.3 and I am getting same exact behavior as in description. Is anyone else seeing this? I updated environment to be a little more specific with my environment in case it that sheds any light on this.
Hide
Bill Dortch added a comment -

The trunk version of jopenssl now supplies the complete OpenSSL::BN class. Not sure when jossl is scheduled for its next release.

Show
Bill Dortch added a comment - The trunk version of jopenssl now supplies the complete OpenSSL::BN class. Not sure when jossl is scheduled for its next release.
Hide
Thomas E Enebo added a comment -

If it works with a newer jossl version then that is great, but I would still like to understand why we have this problem only on windows with the current jossl gem. We must be following a different code path somewhere?

Show
Thomas E Enebo added a comment - If it works with a newer jossl version then that is great, but I would still like to understand why we have this problem only on windows with the current jossl gem. We must be following a different code path somewhere?
Hide
William Gannon added a comment -

The problem appears in the rails-2.0.1\lib\rails_generator\secret_key_generator.rb in the method generate_secret_with_openssl Since OpenSSL::BN.rand method does not exist, I just added a bogus line:

data = "This is some string that should be randomly generated"

instead of

data = OpenSSL::BN.rand(2048, -1, false).to_s

Ok, it's not the best, but it will allow Rails to create a new site.

It appears that the OpenSSL::BN.rand method needs to be defined!!!!

Show
William Gannon added a comment - The problem appears in the rails-2.0.1\lib\rails_generator\secret_key_generator.rb in the method generate_secret_with_openssl Since OpenSSL::BN.rand method does not exist, I just added a bogus line: data = "This is some string that should be randomly generated" instead of data = OpenSSL::BN.rand(2048, -1, false).to_s Ok, it's not the best, but it will allow Rails to create a new site. It appears that the OpenSSL::BN.rand method needs to be defined!!!!
Hide
William Gannon added a comment -

ok, maybe data = "This is some string that should be randomly generated" should be replaced, temporarily with something like:

data = "#{Time.now.to_s}/RoRs Rocks"

Show
William Gannon added a comment - ok, maybe data = "This is some string that should be randomly generated" should be replaced, temporarily with something like: data = "#{Time.now.to_s}/RoRs Rocks"
Hide
Thomas E Enebo added a comment -

Combine William's comments with these and the mystery is solved....

On MacOS and linux magic happens and they end up using generate_secret_with_urandom whereas windows uses generate_secret_with_openssl.

So Bill (Dortch) is correct that we just need to put out a new version of jossl where OpenSSL::BN is properly defined (which is already done in jossl trunk) and all will be golden.

Show
Thomas E Enebo added a comment - Combine William's comments with these and the mystery is solved.... On MacOS and linux magic happens and they end up using generate_secret_with_urandom whereas windows uses generate_secret_with_openssl. So Bill (Dortch) is correct that we just need to put out a new version of jossl where OpenSSL::BN is properly defined (which is already done in jossl trunk) and all will be golden.
Hide
William Gannon added a comment -

I thought I would try jruby-openssl-0.0.5 from SVN (http://jruby-extras.rubyforge.org/svn/trunk/jopenssl/).

First, I copied the build.properties.SAMPLE to build.properties and made it contain:

C:\jopenssl>cat build.properties
version.target=1.5
version.source=1.5
jruby.home=c:/jruby/head
jruby.jar=${jruby.home}/lib/jruby.jar

  1. set this to an alternate location to compile against a different jruby.jar
  2. jruby.jar=lib/jruby.jar

Next, I ran ant and compiled.

Next, I ran jruby on jruby-openssl.gemspec and successfully created a new gem

Next, did jruby -S gem install jruby-openssl -v 0.0.5 and successfully installed the gem

However, when running jruby -S rails railsapp1, I get the following message:

uninitialized constant Digest::SHA2

So I looked in rails-2.0.1\lib\rails_generator\secret_key_generator.rb again and see the it requires 'openssl', but 'openssl' requires 'jopenssl' which does not exist in the jrbuy lib...shouldn't this have been installed with the gem package?

I thought I compiled the jruby-openssl correctly but apparently I have not.

Show
William Gannon added a comment - I thought I would try jruby-openssl-0.0.5 from SVN (http://jruby-extras.rubyforge.org/svn/trunk/jopenssl/). First, I copied the build.properties.SAMPLE to build.properties and made it contain: C:\jopenssl>cat build.properties version.target=1.5 version.source=1.5 jruby.home=c:/jruby/head jruby.jar=${jruby.home}/lib/jruby.jar
  1. set this to an alternate location to compile against a different jruby.jar
  2. jruby.jar=lib/jruby.jar
Next, I ran ant and compiled. Next, I ran jruby on jruby-openssl.gemspec and successfully created a new gem Next, did jruby -S gem install jruby-openssl -v 0.0.5 and successfully installed the gem However, when running jruby -S rails railsapp1, I get the following message: uninitialized constant Digest::SHA2 So I looked in rails-2.0.1\lib\rails_generator\secret_key_generator.rb again and see the it requires 'openssl', but 'openssl' requires 'jopenssl' which does not exist in the jrbuy lib...shouldn't this have been installed with the gem package? I thought I compiled the jruby-openssl correctly but apparently I have not.
Hide
William Gannon added a comment -

Doh...maybe I should read my docs more!!!

Ran gem build jruby-openssl.gemspec and got the correct gem file.

Show
William Gannon added a comment - Doh...maybe I should read my docs more!!! Ran gem build jruby-openssl.gemspec and got the correct gem file.
Hide
Nick Sieger added a comment - - edited

I believe this is fixed now, and should work even without the openssl gem installed. Stub versions of OpenSSL::Digest and HMAC are built-in, as is 1.9's SecureRandom class which should take precedence in the secret_key_generator.

Show
Nick Sieger added a comment - - edited I believe this is fixed now, and should work even without the openssl gem installed. Stub versions of OpenSSL::Digest and HMAC are built-in, as is 1.9's SecureRandom class which should take precedence in the secret_key_generator.
Hide
Alberto Luiz Souza added a comment -

Hi, i'm trying to get started with JRuby reading the JRuby on Rails..., i installed the last version of JRuby, get the latest Ruby version etc... I followed your tips to run rails command to create an application but the error remains. There is a step by step to make run this command with those versions of Ruby and JRuby?

Show
Alberto Luiz Souza added a comment - Hi, i'm trying to get started with JRuby reading the JRuby on Rails..., i installed the last version of JRuby, get the latest Ruby version etc... I followed your tips to run rails command to create an application but the error remains. There is a step by step to make run this command with those versions of Ruby and JRuby?
Show
Vladimir Sizikov added a comment - Please try these resources for simple step-by-step instructions: http://wiki.jruby.org/wiki/Running_Rails_with_ActiveRecord-JDBC http://blog.emptyway.com/2008/04/08/120-seconds-guide-to-jruby-on-rails|

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: