Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Installing Gems in jruby 1.7.11-SNAPSHOT java.lang.NoClassDefFoundError: org/bouncycastle/asn1/DERBoolean #1489

Closed
scarcher2 opened this Issue Feb 6, 2014 · 18 comments

Comments

Projects
None yet
7 participants
@scarcher2
Copy link

scarcher2 commented Feb 6, 2014

I just downloaded a 1.7.11 snapshot of jruby and went to install rails.
I received the error listed below:

C:\opt\ruby\jruby-1.7.11-SNAPSHOT>jruby -S gem install rails
ERROR:  Loading command: install (LoadError)
        load error: jopenssl/load -- java.lang.NoClassDefFoundError: org/bouncycastle/asn1/DERBoolean
ERROR:  While executing gem ... (NoMethodError)
    undefined method `invoke_with_build_args' for nil:NilClass
C:\opt\ruby\jruby-1.7.11-SNAPSHOT>
C:\opt\ruby\jruby-1.7.11-SNAPSHOT>jruby -v
jruby 1.7.11-SNAPSHOT (1.9.3p392) 2014-02-06 c5d0e22 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_45-b18 [Windows 7-amd64]

I downloaded the dist.zip file and unzipped it. Changed my JRUBY_HOME / PATH and tried to install rails. It actually does this when you try to install any gem though.

@scarcher2

This comment has been minimized.

Copy link
Author

scarcher2 commented Feb 7, 2014

I've also checked out / built the current 1.7 branch and I get the same error when I try to install a gem.

@mkristian

This comment has been minimized.

Copy link
Member

mkristian commented Feb 7, 2014

could you add
-Xdebug.loadService=true
to the jruby command (hopefully that is the right syntax for windows ;)
and see what it is doing with the /lib/ruby/shared/bcpkix-jdk15on-1.47.jar
which should also part of your installation.

  • christian

On Fri, Feb 7, 2014 at 8:05 PM, Scott Archer notifications@github.comwrote:

I've also checked out / built the current 1.7 branch and I get the same
error when I try to install a gem.


Reply to this email directly or view it on GitHubhttps://github.com//issues/1489#issuecomment-34496485
.

@scarcher2

This comment has been minimized.

Copy link
Author

scarcher2 commented Feb 7, 2014

This looks awful, but that's thanks to Microsoft's Command Prompt - https://gist.github.com/scarcher2/8873683

I was doing some debugging and I added some logging to
lib/ruby/shared/bouncy-castle-java.rb
It doesn't actually print anything.
I even tried hard coding a require for the bouncycastle .jars and it still wouldn't work.

Dir[File.expand_path('bc*.jar', File.dirname(__FILE__))].each do |file|
   puts 'TEST'
  require File.basename(file)
end
@ratnikov

This comment has been minimized.

Copy link
Contributor

ratnikov commented Feb 9, 2014

Does that Dir[] find the expected jars? If not, it could be a regression due to the Dir.glob refactor.

@BanzaiMan BanzaiMan added the openssl label Feb 9, 2014

@scarcher2

This comment has been minimized.

Copy link
Author

scarcher2 commented Feb 9, 2014

It does not find the .jar files.

@ratnikov

This comment has been minimized.

Copy link
Contributor

ratnikov commented Feb 9, 2014

Do you have access to *nix environment to check if it's a windows only regression? I'll try to reproduce it later today.

@scarcher2

This comment has been minimized.

Copy link
Author

scarcher2 commented Feb 10, 2014

I tested this in Linux and it worked properly. It does look like it is a windows only problem.

archer@ubuntu:~/opensource/jruby$ jruby -v
jruby 1.7.11-SNAPSHOT (1.9.3p392) 2014-02-10 b6b149d on OpenJDK 64-Bit Server VM 1.6.0_27-b27 [linux-amd64]
archer@ubuntu:~/opensource/jruby$ jruby -S gem install rails
Fetching: i18n-0.6.9.gem (100%)
Successfully installed i18n-0.6.9
Fetching: multi_json-1.8.4.gem (100%)
Successfully installed multi_json-1.8.4
Fetching: tzinfo-0.3.38.gem (100%)
Successfully installed tzinfo-0.3.38
Fetching: atomic-1.1.14-java.gem (100%)
Successfully installed atomic-1.1.14-java
Fetching: thread_safe-0.1.3-java.gem (100%)
Successfully installed thread_safe-0.1.3-java
Fetching: activesupport-4.0.2.gem (100%)
Successfully installed activesupport-4.0.2
...
@scarcher2

This comment has been minimized.

Copy link
Author

scarcher2 commented Feb 10, 2014

I'm not sure if this is relevant, but the bootstrap tests fail on windows currently also:

[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ jruby-tests ---
[INFO]
[INFO] --- gem-maven-plugin:1.0.0-rc2:initialize (default) @ jruby-tests ---
[WARNING] ERROR:  Loading command: install (LoadError)
[WARNING]       load error: jopenssl/load -- java.lang.NoClassDefFoundError: org/bouncycastle/asn1/DERBoolean
[WARNING] ERROR:  While executing gem ... (NoMethodError)
[WARNING]     undefined method `invoke_with_build_args' for nil:NilClass
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] JRuby ............................................. SUCCESS [0.335s]
[INFO] JRuby Core ........................................ SUCCESS [26.538s]
[INFO] JRuby Ext ......................................... SUCCESS [0.013s]
[INFO] JRuby OpenSSL ..................................... SUCCESS [0.773s]
[INFO] JRuby Readline .................................... SUCCESS [0.159s]
[INFO] JRuby Ripper ...................................... SUCCESS [0.330s]
[INFO] JRuby Integration Tests ........................... FAILURE [11.154s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 39.566s
[INFO] Finished at: Mon Feb 10 09:47:25 CST 2014
[INFO] Final Memory: 31M/604M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal de.saumya.mojo:gem-maven-plugin:1.0.0-rc2:initialize (default) on project jruby-tests: Execution de
fault of goal de.saumya.mojo:gem-maven-plugin:1.0.0-rc2:initialize failed: Java returned: 1 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :jruby-tests
C:\code\opensource\jruby>
@ratnikov

This comment has been minimized.

Copy link
Contributor

ratnikov commented Feb 10, 2014

Thanks! Once I find a windows environment to try to reproduce this, I will. :)

If you're feeling adventurous, I think this may be the culprit: https://github.com/jruby/jruby/blob/jruby-1_7/core/src/main/java/org/jruby/util/Dir.java#L594 So you could try commenting out and trying to recompile until I get my windows environment setup.

@scarcher2

This comment has been minimized.

Copy link
Author

scarcher2 commented Feb 10, 2014

I noticed if I change bouncy-castle-java.rb from

Dir[File.expand_path('bc*.jar', File.dirname(__FILE__))].each do |file|
  require File.basename(file)
end

to

Dir[File.dirname(__FILE__) + '/bc*.jar'].each do |file|
  require File.basename(file)
end

It works properly.

@scarcher2

This comment has been minimized.

Copy link
Author

scarcher2 commented Feb 10, 2014

So the only difference is the type of slash in the path.

File.expand_path = [C:\code\opensource\jruby\lib\ruby\shared\bc*.jar]
File.dirname(__FILE__) + '/bc*.jar'= [C:/code/opensource/jruby/lib/ruby/shared/bc*.jar]

So the regression bug is either expand path needs to convert the '' to '/' or Dir needs to work with both '' as well as '/'

@scarcher2

This comment has been minimized.

Copy link
Author

scarcher2 commented Feb 10, 2014

This is an easier way to test it out:
https://gist.github.com/anonymous/8921030

#does not print anything
Dir["c:\\code\\opensource\\jruby\\*"].each do |file|
puts '\\' + file
end

#prints files in the directory
Dir["c:/code/opensource/jruby/*"].each do |file|
puts '/' + file
end
@dabdine

This comment has been minimized.

Copy link

dabdine commented Feb 14, 2014

I've also experienced the same while doing a "require 'openssl'" from a script on MacOSX 10.9 w/jruby 1.7.10. Reverted to using jruby-openssl for now.

@scarcher2

This comment has been minimized.

Copy link
Author

scarcher2 commented Feb 14, 2014

I tried doing a

require 'openssl'

with the jruby-complete-1.7.11-SNAPSHOT.jar, This also does not work

C:\code\opensource\jruby>java -jar jruby-complete-1.7.11-SNAPSHOT.jar test_ssl.rb
Considering: file:/C:/code/opensource/jruby/jruby-complete-1.7.11-SNAPSHOT.jar!/META-INF/jruby.home/lib/ruby/gems/shared/specifica
tions/default/*.gemspec
Resource: org.jruby.util.JarDirectoryResource@7df93c3c
Considering: file:/C:/code/opensource/jruby/jruby-complete-1.7.11-SNAPSHOT.jar!/META-INF/jruby.home/lib/ruby/gems/shared/specifica
tions/default/*.gemspec
Resource: org.jruby.util.JarDirectoryResource@a53ed8f
Considering: file:/C:/code/opensource/jruby/jruby-complete-1.7.11-SNAPSHOT.jar!/META-INF/jruby.home/lib/ruby/gems/shared/specifica
tions/*.gemspec
Resource: org.jruby.util.JarDirectoryResource@e4f087f
Considering: file:C:\code\opensource\jruby\jruby-complete-1.7.11-SNAPSHOT.jar!\META-INF\jruby.home\lib\ruby\shared\bc*.jar
Resource: C:/code/opensource/jruby/.
LoadError: load error: jopenssl/load -- java.lang.NoClassDefFoundError: org/bouncycastle/asn1/DERBoolean
  require at org/jruby/RubyKernel.java:1085
  require at file:/C:/code/opensource/jruby/jruby-complete-1.7.11-SNAPSHOT.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_
ext/kernel_require.rb:55
   (root) at file:/C:/code/opensource/jruby/jruby-complete-1.7.11-SNAPSHOT.jar!/META-INF/jruby.home/lib/ruby/shared/openssl.rb:1
  require at org/jruby/RubyKernel.java:1085
   (root) at file:/C:/code/opensource/jruby/jruby-complete-1.7.11-SNAPSHOT.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_
ext/kernel_require.rb:1
   (root) at test_ssl.rb:1
@ratnikov

This comment has been minimized.

Copy link
Contributor

ratnikov commented Feb 18, 2014

I've just sent a patch that should fix the underlying issue of doing require "openssl" (I've tested it locally on windows with Cygwin).

Seems like Dir["c:\code\opensource\jruby*"] returning an empty set is a red herring: apparently both jruby 1.7.10 and 1.9.3 MRI behave the same way. So the issue was me breaking JRubyFile which used to replace back slashes (which is what java uses for file separators on windows) with forward ones. So the fix is to just roll those changes back.

@mkristian mkristian closed this in 51705b5 Feb 18, 2014

@enebo enebo added this to the JRuby 1.7.11 milestone Feb 21, 2014

@fxgallego

This comment has been minimized.

Copy link

fxgallego commented Jul 16, 2014

Similar error in 1.7.13 jruby -v shows
jruby 1.7.13 (1.9.3p392) 2014-06-24 43f133c on Java HotSpot(TM) 64-Bit Server VM
1.7.0_07-b10 [Windows 7-amd64]

jruby -S gem install rails
ERROR: Loading command: install (OpenSSL::X509::StoreError)
setting default path failed: null
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass

Sorry if it's wrong reported here

@ratnikov

This comment has been minimized.

Copy link
Contributor

ratnikov commented Jul 16, 2014

@fxgallego Your error doesn't seem to be related to jruby fialing to load bouncycastle. Any specific reason you think it might? Otherwise I'd recommend opening a different issue. :)

@fxgallego

This comment has been minimized.

Copy link

fxgallego commented Jul 16, 2014

Sorry I missed the full error msg. Yes no, problem, I'll fill a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.