`java.lang.VerifyError: class org.bouncycastle.asn1.ASN1Primitive` after installing Neo4j-Devise gem on JRuby

StackOverflow https://stackoverflow.com/questions/20843691

Question

I'm pretty new to programming and have been trying to follow the Team Treehouse tutorials. However, whilst working on my own project, I've been building an app with JRuby and Neo4j. I've managed to make my way through a few differences so far, but seem to be stuck now. I've just installed the Neo4j-Devise gem and everything has been working ok, but now I seem to be getting this error whenever I try to start the server... or do anything useful really:

LoadError: load error: jopenssl/load -- java.lang.VerifyError: class org.bouncycastle.asn1.ASN1Primitive overrides final method equals.(Ljava/lang/Object;)Z
require at org/jruby/RubyKernel.java:1083
 (root) at C:/jruby-1.7.9/lib/ruby/gems/shared/gems/jruby-openssl-0.9.4/lib/jruby-openssl.rb:5
require at org/jruby/RubyKernel.java:1083
 (root) at C:/jruby-1.7.9/lib/ruby/gems/shared/gems/bundler-1.3.5/lib/bundler/runtime.rb:1
 each at org/jruby/RubyArray.java:1613
require at C:/jruby-1.7.9/lib/ruby/gems/shared/gems/bundler-1.3.5/lib/bundler/runtime.rb:72
 each at org/jruby/RubyArray.java:1613
require at C:/jruby-1.7.9/lib/ruby/gems/shared/gems/bundler-1.3.5/lib/bundler/runtime.rb:70
require at C:/jruby-1.7.9/lib/ruby/gems/shared/gems/bundler-1.3.5/lib/bundler/runtime.rb:59
require at C:/jruby-1.7.9/lib/ruby/gems/shared/gems/bundler-1.3.5/lib/bundler.rb:132
require at org/jruby/RubyKernel.java:1083
 (root) at C:/Sites/Knock4/config/application.rb:14
  tap at org/jruby/RubyKernel.java:1891
 (root) at C:/jruby-1.7.9/lib/ruby/gems/shared/gems/railties-3.2.16/lib/rails/commands.rb:1
require at org/jruby/RubyKernel.java:1083
 (root) at script/rails:6

I have read a few other pages on here suggesting that similar errors can be caused by differences in Bouncycastle versions, but I've tried changing them (at least I think I have, perhaps I've been doing that wrong!) and I keep getting the same error.

Any assistance would be greatly appreciated!

The gem file is as follows:

source 'https://rubygems.org'
gem 'rails', '3.2.16'
gem 'jruby-openssl'
gem 'devise', '2.2.7'
gem 'devise-neo4j', :git => 'git://github.com/cfitz/devise-neo4j.git', :branch => 'devise2'
group :assets do
 gem 'sass-rails',   '~> 3.2.3'
 gem 'coffee-rails', '~> 3.2.1'
 gem 'therubyrhino'
 gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'

group :development, :test do
 gem "rspec-rails"
end

gem "neo4j", ">= 2.2.0"
gem 'neo4j-admin'
Was it helpful?

Solution

It appears that the neo4j-admin-0.2.0-java gem includes lib/neo4j-admin/jars/bcprov-jdk16-140.jar. Unpacking that JAR shows that there are bouncycastle classes included.

Looking at the docs for ASN1Primitive, we can see that it inherits from ASN1Object. Running javap on the ASN1Object included in the above JAR, we can see what equals is defined as (extra lines removed):

$ javap ASN1Object.class | grep equals
  public final boolean equals(java.lang.Object);

This data correlates with this related question. Looking at the MANIFEST.MF file at the root of the JAR, it says

Implementation-Version: 1.40.0

So JRuby is likely including a newer version of bouncycastle and you have a gem providing an older version; welcome to DLL Hell :-). I'm not sure of the best solution here. You could delete the bcprov JAR as a quick hack, but who knows what that might do. You should check to see if there is a newer version of the neo4j gems that might work around this. If not, you should probably file a bug with them so that they are aware (if there isn't one already).

EDIT

Here is the bug report. It doesn't look to have been worked on in quite a while.

EDIT 2

Of course, if you don't need the neo4j-admin gem, you can probably remove it from your Gemfile and keep on trucking.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top