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

Closed
mindscratch opened this Issue Jan 23, 2014 · 24 comments

Projects

None yet

5 participants

@mindscratch

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?

@mkristian
Member

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.

@mkristian
Member

I tried to reproduce it but could not.

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

@mindscratch

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 😕

@mkristian
Member

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)

@nowhereman

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 ;)

@mkristian
Member

Have a good day ;)

thanx.

still I am still unsure where the real problem is. there is no need for
jruby-openssl in the Gemfile - it is part of jruby-1.7.x

the reason why the bouncy-castle-java jar is not loaded is still not clear.

all I know is if you add the jars to WEB-INF/lib it works - including jboss
and webspere application servers. forcing the warbler to include the
bouncy-castle-java gems apparently helps as well.

I know there is a problem with deployments where there is a space in the
deployment directory: #1477

that will be part of the coming jruby-1.7.11

but I still would like know

  • what OS
  • what jdk version
  • does the deploy directory contain space

just tried it a newly scaffolded rails-3.2.6 application it just starts on
jetty and delivers content.
( java version "1.7.0_51", jruby-1.7.11-SNAPSHOT, wabler-1.4.1.dev,
ubuntu-13.04)

thanx in advance for further input.

-christian

@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
@nowhereman

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

@mkristian
Member

great that is close enough to my ubuntu ;)

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

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

@nowhereman

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.

@nowhereman

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)'
@nowhereman

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

@mkristian
Member

you could try to remove it since it is already included.

hope I find time later to reproduce it at least :)

@mkristian
Member

ok - I found the problem: warbler does a lot of things with all these
vendored jars inside gems, i.e. it copies them to WEB-INF/lib and replaces
the jar inside the gems with an empty jar.

now the problem is that if the gem comes with jruby itself then that
copying does not happen and you end up with some jars from gems in the
tomcat classloader and the other jars packed inside jruby.jar will exists
on the jruby-classloader, i.e. jopenssl as gem will not find the
bouncy-castle jars since the tomcat classloader does not see the
jruby-classloader !! i.e. as you said removing jruby-openssl from you
Gemfile solves the problem since both are already part of jruby itself !!

I personally think warbler is overdoing something here, it really creates a
totally different runtime environment in comparison to jruby -S rails
server. IMO testing/development should be a close as possible to production
!!!

thanx for all the patience with me . . . let's see how to fix this in
warbler.

regards,
christian

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

@mkristian
Member

yes, it should be the warbler patch which gets you going. but the warning
will remain ;)

@mindscratch

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

@mkristian
Member

as long you are not on websphere the new warbler from git head fixed the
problem. if that warbler still produces bad war files please report here ;)

On Thu, Mar 6, 2014 at 11:18 AM, Craig Wickesser
notifications@github.comwrote:

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

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


Reply to this email directly or view it on GitHubhttps://github.com/jruby/jruby/issues/1435#issuecomment-36846016
.

@mkristian
Member

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.
@mkristian
Member

was the point 3 necessary or optional ?

if optional then it is time to close this issue ;)

@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
@mkristian
Member

thanx, right the fix for bouncy-castle-java loading did not go into the
already published gem but the next version will have it.

@ryanfb ryanfb added a commit to ryanfb/sosol that referenced this issue May 15, 2014
@ryanfb 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
@mkristian
Member

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

@mkristian mkristian closed this Jul 8, 2014
@enebo enebo modified the milestone: JRuby 1.7.14, JRuby 1.7.15 Aug 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment