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 running rspec (LoadError: load error: jopenssl/load -- java.lang.NoClassDefFoundError: org/bouncycastle/asn1/DERBoolean) #2079

chriskilding opened this issue Oct 30, 2014 · 13 comments


Copy link

In my Jruby / Rails project, when I attempt to run my Rspec test suite (on Travis) I get the following error:

LoadError: load error: jopenssl/load -- java.lang.NoClassDefFoundError: org/bouncycastle/asn1/DERBoolean

Note that all previous steps including bundle install, bundle exec rake db:migrate etc work fine. The grief just happens when we hit Rspec for some reason, probably because this is the first point that a significant portion of the Rails app is being loaded up.

This happens on the standard Travis Ubuntu build slave VM, building a Ruby project with jruby-19mode (which was jruby-1.7.16 at the last count), on both OpenJDK AND Oracle JDK.

This is the output of 'bundle install' so you can see which gems are being installed. Being Travis, we can be sure that the VM was built from scratch, and that no other old versions of gems or rubies are hanging around by mistake.

Installing rake 10.3.2
Installing i18n 0.6.11
Installing json 1.8.1
Installing minitest 5.4.2
Using thread_safe 0.3.4
Installing tzinfo 1.2.2
Installing activesupport 4.1.6
Installing builder 3.2.2
Installing erubis 2.7.0
Installing actionview 4.1.6
Installing rack 1.5.2
Installing rack-test 0.6.2
Installing actionpack 4.1.6
Installing mime-types 2.4.3
Installing mail 2.6.1
Installing actionmailer 4.1.6
Installing activemodel 4.1.6
Installing active_model_serializers 0.8.2
Installing arel
Installing activerecord 4.1.6
Installing activerecord-jdbc-adapter 1.3.11
Installing jdbc-postgres 9.3.1102
Installing activerecord-jdbcpostgresql-adapter 1.3.11
Using descendants_tracker 0.0.4
Using ice_nine 0.11.0
Using axiom-types 0.1.1
Installing carrierwave 0.10.0
Installing coderay 1.1.0
Using coercible 1.0.0
Installing diff-lcs 1.2.5
Installing dotenv-deployment 0.0.2
Installing dotenv 0.11.1
Installing dotenv-rails 0.11.1
Using equalizer 0.0.9
Installing factory_girl 4.3.0
Installing thor 0.19.1
Installing railties 4.1.6
Installing factory_girl_rails 4.3.0
Installing ffi 1.9.6
Installing hike 1.2.3
Installing jar-dependencies 0.1.4
Using bundler 1.7.3
Using virtus 1.0.3
Using maven-tools 1.0.5
Using ruby-maven-libs 3.1.1
Using ruby-maven
Installing jbundler 0.6.4
Installing jruby-jars
Using jruby-openssl 0.9.5
Installing jruby-rack 1.1.16
Installing method_source 0.8.2
Installing mono_logger 1.1.0
Installing multi_json 1.10.1
Installing slop 3.6.0
Installing spoon 0.0.4
Installing pry 0.10.1
Installing pry-remote 0.1.8
Installing puma 2.8.2
Installing rack-protection 1.5.3
Installing tilt 1.4.1
Installing sprockets 2.12.2
Installing sprockets-rails 2.2.0
Installing rails 4.1.6
Installing redis 3.1.0
Installing redis-namespace 1.5.1
Installing sinatra 1.4.5
Installing vegas 0.1.11
Installing resque 1.25.2
Installing rufus-scheduler 2.0.24
Installing resque-scheduler 3.0.0
Installing resque-status 0.4.3
Installing rspec-core 2.14.8
Installing rspec-expectations 2.14.5
Installing rspec-mocks 2.14.6
Installing rspec-rails 2.14.2
Installing rubyzip 1.1.6
Installing shoulda-matchers 2.6.2
Installing spring 1.1.3
Installing tzinfo-data 1.2014.9
Installing yard
Installing versionist 1.2.1
Installing warbler 1.4.4

FWIW, jbundler is in there because we use a couple of Maven JARs too. It may or may not be messing up the class loading of bouncy castle, but we certainly don't list any bouncy castle or openssl related JARs in the Jarfile.

Copy link

that is not enough info to reproduce the problem. the interesting output
would be to run jruby with:

$ jruby -J-Djruby.debug.loadService=true

which would show how jruby tries to load those bouncy-castle jars whether
they come from the jruby or from the jruby-openssl gem or via jbundler.
apparently they are not loaded at all :(

you are saying it fails on travis but from this I conclude it works on your
machine - is that correct ?

is this by any chance a public/open project ?

Copy link

Sadly no it's proprietary code, so can't show you the rest of the project, although I could reproduce little sanitised bits of it if you need any specific parts.

The project fails on both my own dev box and Travis in the same way.

I have a ~700 line trace from running jruby -J-Djruby.debug.loadService=true if you want it, there is no mention of bouncy castle or openssl in it though. FWIW the command behaves a bit weirdly, I have to press a key before it starts logging, and it sort of hangs after logging the big trace.

Copy link

I take the 700 line trace as a next step - maybe it gives some clues what
goes wrong.

Copy link

Copy link

all I see here is that it ends after loading or while loading the first
gem. it does not even show that jopenssl/load.rb gets loaded.

any minimal Gemfile + Jarfile which produces the error would be helpful,

Copy link

Gemfile with most (but not all) of our app's gems stripped out:

source ''

group :development, :test do
  gem 'jbundler', '~> 0.6.4'
  gem 'dotenv-rails', '~> 0.11.1'
  gem "factory_girl_rails", "~> 4.3.0"
  gem "rake" # For the benefit of travis

gem 'rails', '~> 4.1.6'
gem "puma", '~> 2.8.2'

platforms :jruby do
  gem 'activerecord-jdbcpostgresql-adapter', '~> 1.3.7'

# If I don't leave these in then when I run 'rake spec' it complains about
# resque rake task being missing. Which is interesting because it suggests
# something has managed to load before we hit the DERBoolean error.
gem 'resque', '~> 1.25.2'
gem 'resque-status', '~> 0.4.3'
gem 'resque-scheduler'

group :test do
  gem "rspec-rails", "~> 2.14.0"
  gem 'shoulda-matchers', "~> 2.6.1"

Edit: apparently the contents of the Gemfile have almost nothing to do with it! When I used a blank Jarfile the DERBoolean error went away. Suspect something is up in Jbundler and the way that required Java things interact with required (j)ruby things.

Jarfile that caused DERBoolean error (it seems adding even one jar causes the error):

jar 'com.fasterxml.jackson.core:jackson-core', '2.3.0'

Copy link

Managed to narrow down the error even more. It turns out that using bundle exec rake spec (or just bundle exec rake with the default task set to spec) fails. But bundle exec rspec works!

This is the Rakefile as it stands:

require File.expand_path('../config/application', __FILE__)


task :default => :spec

Copy link

thanx for the input BUT I was not able to reproduce it and I was NOT able to bundle exec rake spec work in a new scaffolded rails application :(

BUT I remembered I did see something similar before #1549 but can not reproduce this either.

Copy link

In a new scaffolded Rails app Test::Unit is (or at least was last I used the generator) the default test framework, so 'rake spec' would have no meaning, only 'rake test' would work. But if you installed Rspec-rails and could not do a 'rake spec' then yeah that is concerning

Copy link

well, bundle exec rspec did run the the scaffolded specs ;) so maybe I did something stupid along the way or maybe it is even related to your problem (just showing it differently) or something else ;)

Copy link

ok - a clean start again and I got the problem reproduced. it is jbundler and rspec somehow forking/spawning the rspec command.

as workaround add

ENV["JARS_NO_REQUIRE"] = 'false'

to your spec/spec_helper.rb

will fix on jar-dependencies (used by jbundler to require jars)

mkristian added a commit to mkristian/jbundler that referenced this issue Nov 28, 2014
this finally fixes #52

Sponsored by Lookout Inc.
Copy link

@themasterchef should be fixed with jbundler-0.7.0

Copy link

Cool - the spec_helper workaround you posted above is working nicely in the meantime.

@enebo enebo added this to the JRuby 1.7.17 milestone Dec 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

3 participants