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

scarcher2 opened this Issue Feb 6, 2014 · 18 comments

7 participants


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>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 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.


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

JRuby Team member

This looks awful, but that's thanks to Microsoft's Command Prompt -

I was doing some debugging and I added some logging to
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)

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

It does not find the .jar files.


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


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

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

[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ jruby-tests ---
[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] 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] ------------------------------------------------------------------------
[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] 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] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :jruby-tests

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: So you could try commenting out and trying to recompile until I get my windows environment setup.


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)


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

It works properly.


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 '/'


This is an easier way to test it out:

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

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

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.


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
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
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
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/
  require at file:/C:/code/opensource/jruby/jruby-complete-1.7.11-SNAPSHOT.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_
   (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/
   (root) at file:/C:/code/opensource/jruby/jruby-complete-1.7.11-SNAPSHOT.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_
   (root) at test_ssl.rb:1
@ratnikov ratnikov added a commit to ratnikov/jruby that referenced this issue Feb 18, 2014
@ratnikov ratnikov Resurrect replacing '\' with '/' in JRubyFile for windows.
This should fix jruby#1489 regression.

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 added a commit that closed this issue Feb 18, 2014
@ratnikov ratnikov Resurrect replacing '\' with '/' in JRubyFile for windows.
This should fix #1489 regression.
@mkristian mkristian closed this in 51705b5 Feb 18, 2014
@enebo enebo added this to the JRuby 1.7.11 milestone Feb 21, 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


@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. :)


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