Question

I have a Ruby on Rails app that I want to compile/package as a WAR file to host in Tomcat. I've added all of the relevant stuff I can find, but the WAR only appears to include the non-JRuby versions of gems. As a result, I get GemNotFound exceptions such as "could not find activerecord-jdbc-adapter" in Tomcat. If I open the WAR file in 7-zip, it does not show any of the JRuby or Java gems under /WEB-INF/gems/gems.

Warbler does not report any errors or warnings, and the WAR appears to contain everything it needs, except for these gems.

(Because this is a lightweight, internal app, I'm using sqlite for now... which explains the sqlite gems. The DB is stored outside the project and configured in the database.yml file.)

The relevant snippet from my Gemfile:

if defined?(JRUBY_VERSION)
  gem 'jdbc-sqlite3'
  gem 'activerecord-jdbc-adapter'
  gem 'activerecord-jdbcsqlite3-adapter'
  gem 'jruby-openssl'
  gem 'jruby-rack'
else
  gem 'sqlite3'
end

I also tried explicitly including/excluding these gems in the warble.rb file:

config.gems -= ["sqlite3"]

config.gems += [
  "jdbc-sqlite3",
  "activerecord-jdbc-adapter",
  "activerecord-jdbcsqlite3-adapter",
  "jruby-openssl",
  "jruby-rack",
  "warbler"
]

As an interesting side note, if I modify my Gemfile to demand the JRuby gems, jruby -S bundle install works fine but warble gives a series of errors stating that the gems are only for use with JRuby. On the other hand, if I try to run it within JRuby (jruby -S warble) I get:

warble aborted!

no such file to load -- jruby_pageant

How can I convince Warbler that I want the JRuby gems?

Edit:

I also tried specifying platforms in the gemfile, as described in this blog post, but this causes warble to stack-overflow.

platforms :jruby do
  gem 'jdbc-sqlite3'
  gem 'activerecord-jdbc-adapter', :require => false
  gem 'activerecord-jdbcsqlite3-adapter', :require => false
  gem 'jruby-openssl'
  gem 'jruby-rack'
end
platforms :ruby do
  gem 'sqlite3'
end

Versions:

  • ruby 1.9.3
  • jruby 1.7.4
  • warbler 1.3.8
Was it helpful?

Solution

So it turns out that I was missing the jruby-pageant gem. Once I added this to the bundle, jruby -S warble produced the expected output.

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