Skip to content
This repository

bouncy-castle-java JARs missing when warbling with JRuby 1.7.10 #1435

Closed
mindscratch opened this Issue · 24 comments

4 participants

Craig Wickesser Christian Meier Nowhere Man filsanet
Craig Wickesser

I have a Rails 3.2.16 app that we recently upgraded to JRuby 1.7.10, however, when we warble, the WAR file no longer contains the bouncy-castle-java JAR files.

To reproduce:

> rvm use jruby-1.7.10
> gem install rails -v 3.2.16
> rails new foobar
> cd foobar
> vim Gemfile
   # add the following
   gem 'warbler'
   gem 'jruby-openssl'
   gem 'jruby-jars', '1.7.10'

> vim Rakefile
   # add the following
   require 'warbler'
   Warbler::Task.new

> rvm --create --rvmrc jruby-1.7.10@foobar
> bundle
> rake war
> mkdir stuff
> cp foobar.war stuff/
> cd stuff/
> unzip foobar.war
> ls -al WEB-INF/lib
   # notice there are no bouncy-castle JARs

I tried using JRuby 1.7.9 and the WAR does include bouncy-castle JARs.

> vim Gemfile
   # change some things
   gem 'jruby-jars', '1.7.9'

> vim .rvmrc
   # change the environment_id to be jruby-1.7.9

> rm Gemfile.lock

> rvm install jruby-1.79
> source .rvmrc
> bundle
> rake war
> rm -rf stuff/*
> cp foobar.war stuff/
> cd stuff/
> unzip foobar.war
> ls -al WEB-INF/lib
   # notice the bouncy-castle JARs do exist

Any ideas?

Christian Meier
Collaborator

the question is whether you get an error when running the war-file ? jruby-1.7.x comes with bouncy-castle jars as part of the jruby-stdlib-1.7.x.jar so that should just work.

Christian Meier
Collaborator

I tried to reproduce it but could not.

actually warbler does not know anything about bouncy-castle. is there any config regarding bouncy-castle.

Craig Wickesser

So the "foobar" app I created was to demonstrate the WAR was missing the bouncy-castle JAR files, but I didn't realize it was included with the jruby-stdlib JAR file, which I guess is why I don't see the JAR file. Interesting, I do see the JAR files if I build the WAR file using JRuby 1.7.9.

Anyhow, I was seeing an error in my real application when I would try to access the app, it would say ClassNotFound DERBoolean (some class in bouncy-castle). That's what led me to look for bouncy-castle, and I noticed that the one up we upgraded to JRuby 1.7.10 was missing the JAR files, our other apps were not.

Now I'm :confused:

Christian Meier
Collaborator

my confusion is that I do not understand how those bouncy-castle jars come into the WEB-INF/lib

there is a problem with some servlet classloader which can not load those jars from within the jruby-stdlib.jar which is probably what you are seeing.

I read recently that including the bouncy-caste-java gem in your Gemfile helped. or other people add the bouncy-castle jars manually to WEB-INF/lib via a warble config. see also #1413 (comment)

Nowhere Man

Hi folks,

I had also the same problem with RVM. A JRuby Rack Exception raised when I deploy my war file in Tomcat:
(LoadError) load error: openssl -- java.lang.NoClassDefFoundError: org/bouncycastle/asn1/DERBoolean

Here a quick fix, remove the file below:
$HOME/.rvm/rubies/jruby-1.7.10/lib/ruby/gems/shared/specifications/default/bouncy-castle-java-1.5.0147.gemspec

Then regenerate your war file and your war deployment should be OK.

Have a good day ;)

Christian Meier
Collaborator
filsanet

I can report the same issue when we upgraded our JRuby from 1.7.9 to 1.7.10. We deploy to JBoss.

  • Linux (CentOS)
  • JDK 1.6.0
  • no spaces in deploy directory
03:24:27,528 INFO  [[/app]] An exception happened during JRuby-Rack startup
Could not find bouncy-castle-java-1.5.0147 in any of the sources
Bundler::GemNotFound: Could not find bouncy-castle-java-1.5.0147 in any of the sources

03:24:27,529 ERROR [[/app]] ERROR: initialization failed
org.jruby.rack.RackInitializationException: Could not find bouncy-castle-java-1.5.0147 in any of the sources
Nowhere Man

@mkristian

but I still would like know
1. what OS
2. what jdk version
3. does the deploy directory contain space

  1. Ubuntu 12.04 with RVM 1.25.17
  2. JDK 1.7.0_51 64-Bit Server
  3. No, it doesn't

In JRuby 1.7.9, I have a $HOME/.rvm/rubies/jruby-1.7.9/lib/ruby/gems/shared/gems/bouncy-castle-java-1.5.0147 directory

In JRuby 1.7.10, I haven't any bouncy-castle-java-1.5.*. sub-folder in $HOME/.rvm/rubies/jruby-1.7.10/lib/ruby/gems/shared/gems directory.
And no $HOME/.rvm/rubies/jruby-1.7.10/lib/ruby/gems/shared/gems/default directory.

Christian Meier
Collaborator
Nowhere Man

which servlet container are you using ? jetty ? tomcat ? or jboss or
websphere ?

Tomcat, via warbler gem.

does you Gemfile contains jruby-openssl or bouncy-castle-java ?

Yes, jruby-openssl gem, but I should try to remove it.

Nowhere Man

When I generate my war file via warbler I have this message:
warning: skipping bouncy-castle-java ($HOME/.rvm/rubies/jruby-1.7.10/lib/ruby/gems/shared/gems/bouncy-castle-java-1.5.0147 does not exist)

Then when I deploy the war file, I have this Tomcat error message:

org.jruby.rack.RackInitializationException: load error: jopenssl/load -- java.lang.NoClassDefFoundError: org/bouncycastle/asn1/DERBoolean
  from org/jruby/RubyKernel.java:1083:in `require'
  from /var/lib/tomcat7/webapps/ROOT/WEB-INF/gems/gems/jruby-openssl-0.9.4/lib/openssl.rb:1:in `(root)'
  from org/jruby/RubyKernel.java:1083:in `require'
  from /var/lib/tomcat7/webapps/ROOT/WEB-INF/gems/gems/activesupport-4.0.2/lib/active_support/key_generator.rb:1:in `(root)'
  from org/jruby/RubyKernel.java:1083:in `require'
  from /var/lib/tomcat7/webapps/ROOT/WEB-INF/gems/gems/activesupport-4.0.2/lib/active_support/key_generator.rb:2:in `(root)'
  from org/jruby/RubyKernel.java:1083:in `require'
  from /var/lib/tomcat7/webapps/ROOT/WEB-INF/gems/gems/railties-4.0.2/lib/rails/application.rb:1:in `(root)'
  from org/jruby/RubyKernel.java:1083:in `require'
  from /var/lib/tomcat7/webapps/ROOT/WEB-INF/gems/gems/railties-4.0.2/lib/rails/application.rb:3:in `(root)'
  from org/jruby/RubyKernel.java:1083:in `require'
  from config/application.rb:3:in `(root)'
  from org/jruby/RubyKernel.java:1099:in `load'
  from /var/lib/tomcat7/webapps/ROOT/WEB-INF/gems/gems/railties-4.0.2/lib/rails.rb:1:in `(root)'
  from org/jruby/RubyKernel.java:1083:in `require'
  from config/environment.rb:2:in `(root)'
  from org/jruby/RubyKernel.java:1099:in `load'
  from /var/lib/tomcat7/webapps/ROOT/WEB-INF/gems/gems/railties-4.0.2/lib/rails.rb:9:in `(root)'
  from org/jruby/RubyKernel.java:1083:in `require'
  from /var/lib/tomcat7/webapps/ROOT/WEB-INF/gems/gems/railties-4.0.2/lib/rails/all.rb:1:in `(root)'
  from /var/lib/tomcat7/webapps/ROOT/WEB-INF/gems/gems/railties-4.0.2/lib/rails/all.rb:1:in `(root)'
  from /var/lib/tomcat7/webapps/ROOT/WEB-INF/config/application.rb:1:in `(root)'
Nowhere Man

When I remove the jruby-openssl gem in my Gemfile, it's OK.

Christian Meier
Collaborator
Christian Meier
Collaborator
filsanet

Christian, great news! I spent 4 hours yesterday testing 1.7.11 and still running into the same problem...

warning: skipping bouncy-castle-java (/home/lofsemci/opt/jruby/jruby-1.7.11/lib/ruby/gems/shared/gems/bouncy-castle-java-1.5.0147 does not exist)

Hopefully the warbler patch will fix it.

Christian Meier
Collaborator
Craig Wickesser

I just tried JRuby 1.7.11 also and still have the problem. I just tried the work around posted by @nowhereman and that worked:

$HOME/.rvm/rubies/jruby-1.7.11/lib/ruby/gems/shared/specifications/default/bouncy-castle-java-1.5.0147.gemspec

Christian Meier
Collaborator
Christian Meier
Collaborator

adding WEB-INF/init.rb to the war file with
require 'bcpkix-jdk15on-1.47.jar'
require 'bcprov-jdk15on-1.47.jar'

should fix the problem. please let me know if that helps. I needed to add this for most servlet containers when I worked on https://github.com/mkristian/war-pack. will be not needed for the next jruby 1.7.12 since the loading of the bouncy-castle jars is more robust now.

filsanet

Good news! I was able to resolve this issue by:
1. upgrading to JRuby 1.7.12
2. upgrading warbler to 1.4.2
3. removing jruby-openssl from my Gemfile as @nowhereman recommends.

Christian Meier
Collaborator
filsanet

Sadly, point 3 was required for me.

If I left jruby-openssl in my Gemfile, I continued to get this error and my app would not initialize in JBoss:

Could not find bouncy-castle-java-1.5.0147 in any of the sources
Christian Meier
Collaborator
Ryan Baumann ryanfb referenced this issue from a commit in ryanfb/sosol
Ryan Baumann ryanfb jruby-openssl gem no longer required as it's included in jruby-1.7.x,…
… also fixes potential warbler issue with bouncy-castle-java gem (see: jruby/jruby#1435 jruby/warbler#238)
fc577d9
Christian Meier
Collaborator

we released jruby-openssl-0.9.5.gem which comes bundled with jruby-1.7.13 with a fix for this issue.

Christian Meier mkristian closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.