Jruby 1.5.2 - Rails 3 - Tomcat 6 deployment

Hi,

I’ve developed a Jruby app which is working fine in development using
webrick. However my production environment has an install of tomcat-6
(no jruby/rails install), from some reading it appears warbler should
package my app for me to push the war file to the tomcat and all should
be well.

However up restarting tomcat and viewing any page I seem to get an error
referring to bundler

Has anyone have any advice on what to do next, as google has very little
to go on.

Thanks

/Log Trace/
SEVERE: Application Error
org.jruby.rack.RackInitializationException: uninitialized constant
Bundler
from
file:/usr/local/tomcat6/webapps/bugtrack/WEB-INF/lib/jruby-rack-1.0.3.jar!/jruby/rack/rails.rb:157:in
load_environment' from file:/usr/local/tomcat6/webapps/bugtrack/WEB-INF/lib/jruby-rack-1.0.3.jar!/jruby/rack/rails.rb:165:into_app’
from
file:/usr/local/tomcat6/webapps/bugtrack/WEB-INF/lib/jruby-rack-1.0.3.jar!/jruby/rack/rails.rb:186:in
new' from <script>:2 from file:/usr/local/tomcat6/webapps/bugtrack/WEB-INF/lib/jruby-rack-1.0.3.jar!/vendor/rack-1.2.1/rack/builder.rb:46:ininstance_eval’
from
file:/usr/local/tomcat6/webapps/bugtrack/WEB-INF/lib/jruby-rack-1.0.3.jar!/vendor/rack-1.2.1/rack/builder.rb:46:in
initialize' from <script>:2:innew’
from :2

at
org.jruby.rack.DefaultRackApplicationFactory$4.init(DefaultRackApplicationFactory.java:184)
at
org.jruby.rack.DefaultRackApplicationFactory.getApplication(DefaultRackApplicationFactory.java:59)
at
org.jruby.rack.PoolingRackApplicationFactory.getApplication(PoolingRackApplicationFactory.java:94)
at
org.jruby.rack.servlet.DefaultServletDispatcher.process(DefaultServletDispatcher.java:36)
at org.jruby.rack.RackFilter.doFilter(RackFilter.java:59)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:636)
Caused by: org.jruby.exceptions.RaiseException: uninitialized constant
Bundler
at Module.const_missing(config/boot.rb:7)
at
Kernel.require(file:/usr/local/tomcat6/webapps/bugtrack/WEB-INF/lib/jruby-rack-1.0.3.jar!/jruby/rack/rails.rb:157)
at
JRuby::Rack::RailsBooter::Rails3Environment.load_environment(file:/usr/local/tomcat6/webapps/bugtrack/WEB-INF/lib/jruby-rack-1.0.3.jar!/jruby/rack/rails.rb:165)
at
JRuby::Rack::RailsBooter::Rails3Environment.to_app(file:/usr/local/tomcat6/webapps/bugtrack/WEB-INF/lib/jruby-rack-1.0.3.jar!/jruby/rack/rails.rb:186)
at #Class:01x1d07e4.new(:2)
at
(unknown).(unknown)(file:/usr/local/tomcat6/webapps/bugtrack/WEB-INF/lib/jruby-rack-1.0.3.jar!/vendor/rack-1.2.1/rack/builder.rb:46)
at
Kernel.instance_eval(file:/usr/local/tomcat6/webapps/bugtrack/WEB-INF/lib/jruby-rack-1.0.3.jar!/vendor/rack-1.2.1/rack/builder.rb:46)
at
Kernel.instance_eval(file:/usr/local/tomcat6/webapps/bugtrack/WEB-INF/lib/jruby-rack-1.0.3.jar!/vendor/rack-1.2.1/rack/builder.rb:46)
at Rack::Builder.initialize(:2)
at (unknown).new(:2)
at (unknown).(unknown)(:1)

In order to get things working I had to list bundler as an actual
dependency in the Gemfile, which seems like a circular reference, but
that’s what actually installs bundler into your app directory as a
dependency on your server side, ie when you run bundle install, so yes
you need bundler installed on the server, but the gem also needs to be
copied into your app’s gem_path

Depending on how you’ve configured things, either warbler is packaging
your gems, or you’re installing them on the server side. Either way, if
bundler isn’t listed there, it’s only installed as a system gem on your
server, but likely not in the gem_path of your app. I hope that’s the
right terminology, i’m not an expert on the matter, but that’s the way I
understand it.

As a side note, check out trinidad, i’ve had great success using it for
Rack applications, it wraps Tomcat7 and abstracts a lot of the annoying
tomcat config for you.

On Tue, Nov 23, 2010 at 5:36 PM, Nathan Willoughby
[email protected] wrote:

Has anyone have any advice on what to do next, as google has very little
to go on.

I actually found using warbler not very easy. I recently had to
package an application as a complete jar file, and what I did was to
include the gems as subdirectories inside a jruby-complete jar file.

Pretty neat trick (using 7-zip, I’m on windows for this task), which
you can also use with your jdbc connectors and have the whole app
bundled as a single jar: the last step is to modify MANIFEST.MF


Christian

On Tue, Nov 23, 2010 at 11:49 AM, Christian MICHON
[email protected] wrote:

referring to bundler

Has anyone have any advice on what to do next, as google has very little
to go on.

I actually found using warbler not very easy.

Just curious, is there anything you can mention about your experience
that made it difficult? I’m always looking to improve Warbler.

Thanks,
/Nick

On Tue, Nov 23, 2010 at 7:03 PM, Nick S. [email protected]
wrote:

I actually found using warbler not very easy.

Just curious, is there anything you can mention about your experience
that made it difficult? I’m always looking to improve Warbler.

I tried to use warbler not on a rails app, maybe this was my mistake
after all.

Never managed to make it work. But as I said, quite likely not
applicable. I’ll try warbler soon with a small rails testcase.


Christian

On Tue, Nov 23, 2010 at 10:36 AM, Nathan Willoughby
[email protected] wrote:

Has anyone have any advice on what to do next, as google has very little
to go on.

Did Bundler get included in your war file by Warbler? A quick “jar tf
app.war | grep bundler” should tell you.

I wonder if there isn’t a bug here somewhere between JRuby,
JRuby-Rack, Warbler and Bundler. I’ve been hearing of a few other
cases of this problem lately. For example:

Not the same, but there is the similar symptom of a missing Bundler.

If putting Bundler as a dependency in your Gemfile works, that’s great
but there is probably a larger issue here. Keep us posted on your
findings.

Thanks,

/Nick

Hi Nick,

Checking the generated war file is does appear bundlee is not present.
So
I guess this could be a bug somewhere.

Ill give the beta 1 release a go and see if I have the same problem

Thanks for your help everyone

Nathan

On Tue, Nov 23, 2010 at 12:11 PM, Christian MICHON
[email protected] wrote:

applicable. I’ll try warbler soon with a small rails testcase.
If you wanted to use it on a regular Ruby app (not a webapp), you
might be interested in the new Warbler 1.3.0.beta1. I still need to do
a writeup and release 1.3.0, but until then here are some examples:

/Nick

Hi Christian,

On your tomcat server do you have a jruby installation ?

Thanks
Nathan

On Tue, Nov 23, 2010 at 8:18 PM, Nick S. [email protected]
wrote:

Never managed to make it work. But as I said, quite likely not
applicable. I’ll try warbler soon with a small rails testcase.

If you wanted to use it on a regular Ruby app (not a webapp), you
might be interested in the new Warbler 1.3.0.beta1. I still need to do
a writeup and release 1.3.0, but until then here are some examples:

well, I prefer to keep my custom solution based on 7-zip for the time
being (I need stability). I might look again at warbler-1.3.0 in a
quarter or so.

I just spent 1/2 hour on jruby+rails3+warbler+tomcat6: it works out of
the box, NICE!

1 small drawback though: the WEB-INF\db is not created in the war by
default, so the 1st migration failed. In the end, I used 7-zip to add
db in the war: is there an option for this ?

Here’s my setup:
jruby-1.5.5
rails-3.0.3
tomcat-6.0.29
warbler-1.2.1


Christian

Ah okay,

After some more testing I have installed jruby on the tomcat server
which has removed the bundler error :).

However after removing the jruby install it broke and also after
upgrading to the beta 1 warbler version the error remained.

I have also tried adding bundler to my Gemfile but it did not seem to
get added to package.

So until then it appears jruby is required to be installed on my server

On Wed, Nov 24, 2010 at 11:14 AM, Nathan Willoughby
[email protected] wrote:

Hi Christian,

On your tomcat server do you have a jruby installation ?

yes


Christian

On Wed, Nov 24, 2010 at 12:57 PM, Nathan Willoughby
[email protected] wrote:

So until then it appears jruby is required to be installed on my server

I do not think this is related to jruby being there or not. I actually
managed rails-2.3.9 or rails-3.0.3 (both with bundler-1.0.7) inside
war files deployed on a tomcat server where there was no jruby at all.

What was stopping me was that my db folder (where my
production.sqlite3 is) was not included in the war file.


Christian

I’m late to the conversation, but I’ve been having a heck of a time
packaging a custom app to Tomcat using warbler. It’s a Rails 3.0.3
app, and I am not proficient in Builder yet, but I am getting the same
error - “uninitialized constant
Bundler” when using warbler. Frustrating, this will be a packaged app
I’m hoping to distribute. I’m not sure where the issue is, I’m
running locally on OSX / Webrick, trying to move to Solaris/Tomcat . I
also have custom gems that aren’t on rubygems; that may be part of it.

Almost didn’t post this, since it only adds noise to the conversation,
but not quite sure about the fix for the Bundler Constant error.

Chris

I am also experiencing the same problem - “uninitialized constant
Bundler”. Apparently reason is the fact that “bundler” gem is not
included in the war file. Requiring “bundler” in the Gemfile doesn’t
help. This happens in the situation when warbler is run on the
deployment server where code is uploaded by means of Capistrano, i.e.
gems are residing in the shared/ directory.
However, when “warble” is run locally on the development machine (which
has exactly the same setup), then .war file is created correctly, i.e.
bundle gem is included.
I tried different setup options in the config/warble.eb configuration
file in order to force include Bundler, but that doesn’t help.

I am not aware of how to solve this issue and any help will be
appreciated.

Setup: warbler 1.2.1, bundler 1.0.7, jruby 1.5.5, JBoss 6

Though i’ve since switched to Trinidad, which has negated the use of
Warbler, when we were running a stock Tomcat6 app, I disabled warbler’s
gem packaging with bundler and just ran a manual bundle install during
my deployment in the unpacked war directory, keeping bundler as a
dependency in the Gemfile so it also gets installed. This always worked
for me.

BTW check out Trinidad if you haven’t already. It will run your rails
app with the standard rails directory structure, no need for building
wars. It greatly simplified my deployment process, uses Tomcat under
the hood and also provides a ton of goodies such as hot-deploy,
jdbc-pooling, enhanced log4j support and more.

On Wed, Nov 24, 2010 at 4:12 AM, Christian MICHON
[email protected] wrote:

I tried to use warbler not on a rails app, maybe this was my mistake after
all.
quarter or so.

I just spent 1/2 hour on jruby+rails3+warbler+tomcat6: it works out of
the box, NICE!

1 small drawback though: the WEB-INF\db is not created in the war by
default, so the 1st migration failed. In the end, I used 7-zip to add
db in the war: is there an option for this ?

Sure, there’s a config option to add the ‘db’ directory. Generate a
configuration with “warble config” and have a look in
config/warble.rb. In the future I might end up just adding this
directory in by default to make running migrations from a war file
easier.

/Nick

Hi everyone,

I am experiencing the same problem. I am trying to deploy a sample
rails3 app on EngineYard AppCloud. JRuby option is still in beta. I have
tried including gem ‘bundler’ in my Gemfile, as suggested workaround
with no success. I would appreciate any help. Here is an extract of my
log:

INFO: Unable to find a supported framework! Checking for rackup (.ru)
file
Dec 29, 2010 7:04:35 AM
org.glassfish.scripting.jruby.RackApplicationChooser which
INFO: Discovered a rackup (.ru) file,
/data/eytest/releases/20101229150405 attempting to launch a framework
from that.
Dec 29, 2010 7:04:35 AM org.glassfish.scripting.jruby.JRubyApplication

INFO: Loading application 20101229150405 at /
Dec 29, 2010 7:04:35 AM com.sun.grizzly.jruby.RackGrizzlyAdapter
INFO: JRuby version is: 1.5.5
Dec 29, 2010 7:04:35 AM com.sun.grizzly.jruby.rack.JRubyRuntime
INFO: New instance of JRuby runtime created in 65 milliseconds
Dec 29, 2010 7:04:35 AM
com.sun.grizzly.jruby.rack.RackApplicationPoolFactory
getRackApplocationPool
SEVERE: uninitialized constant Bundler
from /data/eytest/releases/20101229150405/config/boot.rb:31:in
require' from /usr/jruby-bin/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire’
from
/data/eytest/releases/20101229150405/config/application.rb:1
from
/data/eytest/releases/20101229150405/config/application.rb:31:in
require' from /usr/jruby-bin/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire’
from
/data/eytest/releases/20101229150405/config/environment.rb:2
from
/data/eytest/releases/20101229150405/config/environment.rb:31:in
require' from /usr/jruby-bin/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire’
from /data/eytest/releases/20101229150405/config.ru:3:in
`get_rackup_app’

/data/eytest/releases/20101229150405/config/boot.rb:7: uninitialized
constant Bundler (NameError)
from /data/eytest/releases/20101229150405/config/boot.rb:31:in
require' from /usr/jruby-bin/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire’
from
/data/eytest/releases/20101229150405/config/application.rb:1
from
/data/eytest/releases/20101229150405/config/application.rb:31:in
require' from /usr/jruby-bin/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire’
from
/data/eytest/releases/20101229150405/config/environment.rb:2
from
/data/eytest/releases/20101229150405/config/environment.rb:31:in
require' from /usr/jruby-bin/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire’
from /data/eytest/releases/20101229150405/config.ru:3:in
`get_rackup_app’

Nick, I’m the one who posted that issue. I’ll follow up here and on
Github.

I tried adding Bundler to my Gemfile, to no avail. I found that manually
installing Bundler into my BUNDLE_PATH would make Warbler suck it up
along with the other gems, which solved my problem. Not the prettiest
solution, but it works for now.

I have a minimal JRuby environment with Rake, Bundler, and a few other
gems stored in my repo. I use it to bootstrap an environment on the
server so I can build the war on the server to avoid contaminating it
with code from a working copy.

So, in the end, I had my deployment script do the following:

Using Capistrano…

  1. Check out the repo
  2. Symlink #{release_path}/vendor/bundle to #{shared_path}/vendor/bundle
    to avoid doing a fresh install every time
  3. Do a bundle install for deployment: ./support/jruby/bin/jruby -S support/jruby/lib/ruby/gems/1.8/bin/bundle install --deployment
  4. Install Bundler to vendor/bundle: ./support/jruby/bin/jruby -S gem install bundler -i vendor/bundle/jruby/1.8 -v 1.0.7
  5. Build the .war
  6. Symlink the .war in the webapps directory

Is it possible this bug is the cause of these reports?

Warbler doesn’t package Bundler if BUNDLE_PATH is set in .bundle/config
https://github.com/nicksieger/warbler/issues#issue/3

/Nick