History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: JRUBY-1691
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Blocker Blocker
Assignee: Unassigned
Reporter: Thomas E Enebo
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
JRuby

Rails 2.0.1 not working with trunk

Created: 08/Dec/07 06:36 PM   Updated: 15/Apr/08 03:32 PM
Component/s: OpenSSL
Affects Version/s: JRuby 1.1b1, JRuby 1.0.2
Fix Version/s: JRuby 1.0.3, JRuby 1.1RC1

Time Tracking:
Not Specified

Environment: WINDOZE (W2k; Java 5 (1.5.0_06)) Fresh checkout with both JRuby branch and JRuby trunk


 Description  « Hide
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


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Vladimir Sizikov - 09/Dec/07 03:35 AM
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).

Thomas E Enebo - 09/Dec/07 10:18 AM
This does not happen on MacOS.

Thomas E Enebo - 09/Dec/07 04:04 PM
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.

Bill Dortch - 09/Dec/07 05:41 PM
The trunk version of jopenssl now supplies the complete OpenSSL::BN class. Not sure when jossl is scheduled for its next release.

Thomas E Enebo - 10/Dec/07 09:36 AM
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?

William Gannon - 10/Dec/07 11:43 AM
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!!!!


William Gannon - 10/Dec/07 11:49 AM
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"


Thomas E Enebo - 10/Dec/07 01:05 PM
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.


William Gannon - 10/Dec/07 03:43 PM
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.


William Gannon - 10/Dec/07 03:47 PM
Doh...maybe I should read my docs more!!!

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


Nick Sieger - 13/Dec/07 07:55 PM - 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.

Alberto Luiz Souza - 15/Apr/08 03:25 PM
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?