Help deploying a Rails app to Jetty

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello. I’ve been trying to resolve this for most of the day but can’t
seem to figure it out. What makes it worse is that I’m not terribly
knowledgable about Java deployment, though I’ve deployed a few Lift apps
and thought I had more of a handle on it.

I’m trying to deploy Redmine 1.0.1. Everything seems to be set up just
fine, only if I access /, I get a directory listing of the webapp/
directory (I.e. what you’d normally find in the public/ directory of a
Rails app). Accessing any other URL of the app works just fine, but /
fails.

If I enable Jetty debugging, I see that RackHandler appears to be
called, but then the default handler is called immediately after. There
is definitely a blank route, though I did try setting it to ‘/’ with no
change.

I’m trying all of these tests connected directly to the Jetty server, so
it isn’t an issue between my web server and the container.

I’ve even tried changing the URL match pattern from /* to *, but with no
luck.

The most frustrating aspect of all of this is that I’m running a very
similar setup on a different host, though the versions of Redmine
differ. I’ve diffed the Jetty configs, and aside from the differing
virtual host names, they’re identical. So I don’t know why this fails
today but worked earlier.

It looks like Redmine freezes Rails to 2.3.5. Here is my
config/warble.rb. web.xml is unmodified from Warble 1.2.1:

Disable automatic framework detection by uncommenting/setting to false

Warbler.framework_detection = false

Warbler web application assembly configuration file

Warbler::Config.new do |config|

Features: additional options controlling how the jar is built.

Currently the following features are supported:

- gemjar: package the gem repository in a jar file in WEB-INF/lib

config.features = %w(gemjar)

Application directories to be included in the webapp.

config.dirs = %w(app config lib log vendor tmp)

Additional files/directories to include, above those in config.dirs

config.includes = FileList[“db”]

Additional files/directories to exclude

config.excludes = FileList[“lib/tasks/*”]

Additional Java .jar files to include. Note that if .jar files are

placed

in lib (and not otherwise excluded) then they need not be mentioned

here.

JRuby and JRuby-Rack are pre-loaded in this list. Be sure to

include your

own versions if you directly set the value

config.java_libs += FileList[“lib/java/*.jar”]

Loose Java classes and miscellaneous files to be placed in

WEB-INF/classes.

config.java_classes = FileList[“target/classes/**.*”]

One or more pathmaps defining how the java classes should be copied

into

WEB-INF/classes. The example pathmap below accompanies the

java_classes

configuration above. See

http://rake.rubyforge.org/classes/String.html#M000017

for details of how to specify a pathmap.

config.pathmaps.java_classes << “%{target/classes/,}p”

Path to the pre-bundled gem directory inside the war file. Default

is ‘WEB-INF/gems’. Specify path if gems are already bundled

before running Warbler. This also sets ‘gem.path’ inside web.xml.

config.gem_path = “WEB-INF/vendor/bundler_gems”

Bundler support is built-in. If Warbler finds a Gemfile in the

project directory, it will be used to collect the gems to bundle

in your application. If you wish to explicitly disable this

functionality, uncomment here.

config.bundler = false

An array of Bundler groups to avoid including in the war file.

Defaults to [“development”, “test”].

config.bundle_without = []

Files for WEB-INF directory (next to web.xml). This contains

web.xml by default. If there is an .erb-File it will be processed

with webxml-config. You may want to exclude this file via

config.excludes.

config.webinf_files += FileList[“jboss-web.xml”]

Other gems to be included. You need to tell Warbler which gems

your application needs so that they can be packaged in the war

file.

The Rails gems are included by default unless the vendor/rails

directory is present.

config.gems += [“rack”, “activerecord-jdbcpostgresql-adapter”,
“jruby-openssl”, “ruby-openid”, “bluefeather”]

config.gems << “tzinfo”

Uncomment this if you don’t want to package rails gem.

config.gems -= [“rails”]

The most recent versions of gems are used.

You can specify versions of gems by using a hash assignment:

config.gems[“rails”] = “2.0.2”

You can also use regexps or Gem::Dependency objects for flexibility

or

fine-grained control.

config.gems << /^merb-/

config.gems << Gem::Dependency.new(“merb-core”, “= 0.9.3”)

Include gem dependencies not mentioned specifically. Default is

true, uncomment to turn off.

config.gem_dependencies = false

Array of regular expressions matching relative paths in gems to be

excluded from the war. Defaults to empty, but you can set it like

below, which excludes test files.

config.gem_excludes = [/^(test|spec)//]

Files to be included in the root of the webapp. Note that files in

public

will have the leading ‘public/’ part of the path stripped during

staging.

config.public_html = FileList[“public//*", "doc//*”]

Pathmaps for controlling how public HTML files are copied into the

.war

config.pathmaps.public_html = [“%{public/,}p”]

Pathmaps for controlling how application files are copied into the

.war

config.pathmaps.application = [“WEB-INF/%p”]

Name of the war file (without the .war) – defaults to the basename

of RAILS_ROOT

config.war_name = “mywar”

Name of the MANIFEST.MF template for the war file. Defaults to a

simple

MANIFEST.MF that contains the version of Warbler used to create the

war file.

config.manifest_file = “config/MANIFEST.MF”

When using the ‘compiled’ feature and specified, only these Ruby

files will be compiled. Default is to compile all .rb files in

the application.

config.compiled_ruby_files = FileList[‘app/**/*.rb’]

Value of RAILS_ENV for the webapp – default as shown below

config.webxml.rails.env = ENV[‘RAILS_ENV’] || ‘production’

Application booter to use, one of :rack, :rails, or :merb

(autodetected by default)
config.webxml.booter = :rails

When using the :rack booter, “Rackup” script to use.

- For ‘rackup.path’, the value points to the location of the rackup

script in the web archive file. You need to make sure this file

gets included in the war, possibly by adding it to config.includes

or config.webinf_files above.

- For ‘rackup’, the rackup script you provide as an inline string

is simply embedded in web.xml.

The script is evaluated in a Rack::Builder to load the application.

Examples:

config.webxml.rackup.path = ‘WEB-INF/hello.ru’

config.webxml.rackup = %{require ‘./lib/demo’; run

Rack::Adapter::Camping.new(Demo)}

config.webxml.rackup = require ‘cgi’ &&

CGI::escapeHTML(File.read(“config.ru”))

Control the pool of Rails runtimes. Leaving unspecified means

the pool will grow as needed to service requests. It is recommended

that you fix these values when running a production server!

config.webxml.jruby.min.runtimes = 2

config.webxml.jruby.max.runtimes = 4

JNDI data source name

config.webxml.jndi = ‘jdbc/rails’

end

Thanks.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkx24boACgkQIaMjFWMehWIxUgCfSEn2QUkcHa1r8AQojSsDU6pz
H5MAnjX4g37ozfPEog9JOP9fE4xYa8ZC
=l+4e
-----END PGP SIGNATURE-----


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Wondering if this perhaps isn’t the place for such questions, and if
not, could someone kindly point me to a better one? I’ve been searching
Google for most of the last day for this, so it really does have me
stumped. :slight_smile:

Here’s another detail that may or may not help. I notice that if I
connect directly to the Jetty instance and GET any existing file, that
file is returned. If I GET something that doesn’t exist, the path is
delegated to the Rails app. This would normally be fine, except / exists
as a directory from Jetty’s perspective, so it happily serves up the
content of the directory without even seeing if Rails has anything to
say about it.

Anyhow, I thought I’d share that detail in case it helps anyone to help
me. :slight_smile: I thought that deploying to Jetty would be easier than previous
deployment methods, and it was in the one instance I did manage to get
working, but I think I’ve been over these setups with a fine-tooth comb
and I just don’t see what the difference is.

I also fired up the app using script/server and successfully sent a GET
to /, so it has to be Jetty or the code which interacts with it.

On 08/26/2010 04:50 PM, Nolan D. wrote:

If I enable Jetty debugging, I see that RackHandler appears to be
The most frustrating aspect of all of this is that I’m running a very

Additional files/directories to include, above those in config.dirs

include your
http://rake.rubyforge.org/classes/String.html#M000017

in your application. If you wish to explicitly disable this

config.excludes.

config.gems << Gem::Dependency.new(“merb-core”, “= 0.9.3”)

Files to be included in the root of the webapp. Note that files in

files will be compiled. Default is to compile all .rb files in

When using the :rack booter, “Rackup” script to use.

Rack::Adapter::Camping.new(Demo)}

config.webxml.jndi = ‘jdbc/rails’

end

Thanks.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkx3pn0ACgkQIaMjFWMehWJu7QCdENY2SQgu5mMUHT+U+s1ncDYL
DXcAnj9vfeMGE5qPokoj6CGKRmbIOWmb
=IlcX
-----END PGP SIGNATURE-----


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hi Nolan,

This is a good place for questions, but I know that 2 of the 3 core
contributors to JRuby are in Japan at a conference.

Let me suggest something for your sanity. Install mongrel with ‘jruby
-S gem install mongrel’ and then change directory in to the root of your
app. Make sure that you can start up the app with ‘jruby script/console
production’. If everything works perfectly in mongrel then it is a
jetty problem. If you have the same blank page with your mongrel then
it is a deployment problem of some kind.

Reply back with results.

-Brandon

On Aug 26, 2010, at 2:50 PM, Nolan D. wrote:

directory (I.e. what you’d normally find in the public/ directory of a
Rails app). Accessing any other URL of the app works just fine, but / fails.

I’m pretty sure I ran into this bug as well. The solution was to
downgrade to jruby-rack 1.0.1.

HTH,
Mike


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Cool, thanks for the tip re: the conference. I know that deployment is
one of those problems with lots of moving parts, and wasn’t sure if a
list about the language was the best place for those sorts of questions.

I did run script/server without Mongrel, and / was served up just fine.
So it’s definitely a Jetty issue.

To save my sanity, I set up a regexp rewrite of / to one of the Redmine
URLs and this works, even hiding the fact that a new URL was referenced.
I may try downgrading jruby-rack as suggested elsewhere, but for the
moment I can actually put this problem aside and work on others. :slight_smile:

Where does one file issues for jruby-rack?

On 08/27/2010 08:27 AM, Brandon H. wrote:

it is a deployment problem of some kind.

content of the directory without even seeing if Rails has anything to

Rails app). Accessing any other URL of the app works just fine, but /
so
today but worked earlier.

Features: additional options controlling how the jar is built.

include your
java_classes

Bundler support is built-in. If Warbler finds a Gemfile in the

web.xml by default. If there is an .erb-File it will be processed

“jruby-openssl”, “ruby-openid”, “bluefeather”]
flexibility or

below, which excludes test files.

.war

config.compiled_ruby_files = FileList[‘app/**/*.rb’]

rackup

Rack::Adapter::Camping.new(Demo)}

JNDI data source name

config.webxml.jndi = ‘jdbc/rails’

end

Thanks.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkx31AkACgkQIaMjFWMehWIE+gCfcq2y4LKLspsN1XGzlKFqqBwG
/Y8An2wbhMFBax2uiHpiBFznwXEDqvDV
=mAPg
-----END PGP SIGNATURE-----


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/27/2010 09:57 AM, Mike L. wrote:

I’m pretty sure I ran into this bug as well. The solution was to downgrade to jruby-rack 1.0.1.

Aha! My old, functional app is being deployed into Jetty’s work/
directory to preserve Redmine’s files subdir of RAILS_ROOT (if there’s a
better solution for this then do let me know, but it looks like lots of
Rails apps assume a persistent root) which means that old jars from
previous deployments hang around unless I explicitly clean them. As
such, I’m pretty sure there’s an old, functional jruby-rack-1.0.1.jar
hanging around in the functional installation but not in the broken one.

Is there an issue filed for this? If not, where would one go to do so?

Thanks, haven’t tested this yet but it would certainly fit the facts.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkx31NsACgkQIaMjFWMehWKyzACfbbo6JQpqpv/3NZLddgqdBl0H
5PoAn0WBatUrTmtwu9/PhtEQ76hunxsb
=kEIX
-----END PGP SIGNATURE-----


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hi Nolan,

On Fri, Aug 27, 2010 at 10:08 AM, Nolan D. [email protected]
wrote:

Rails apps assume a persistent root) which means that old jars from
previous deployments hang around unless I explicitly clean them. As
such, I’m pretty sure there’s an old, functional jruby-rack-1.0.1.jar
hanging around in the functional installation but not in the broken one.

Is there an issue filed for this? If not, where would one go to do so?

Please go ahead and file an issue here:
http://kenai.com/jira/browse/JRUBY_RACK

Which version of Jetty are you using? If you can isolate any further
what broke between 1.0.1 and newer versions it would be a great help.

Thanks,
/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Aug 30, 2010, at 8:01 AM, Nick S. wrote:

Please go ahead and file an issue here: http://kenai.com/jira/browse/JRUBY_RACK

Which version of Jetty are you using? If you can isolate any further
what broke between 1.0.1 and newer versions it would be a great help.

filed with steps to reproduce
http://kenai.com/jira/browse/JRUBY_RACK-35


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 09/14/2010 02:46 PM, Mike L. wrote:

filed with steps to reproduce
http://kenai.com/jira/browse/JRUBY_RACK-35

Ack, thanks. Been meaning to get around to filing this, but the only
servers I had to play with were sort of in production, and I hadn’t made
time to set it all up locally.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkyP0fcACgkQIaMjFWMehWIl3wCfUID+EnOQseocnNaBEFIkTypF
uOEAn3ffzmouRdzqnKTwDsZvzOinMFhM
=l36i
-----END PGP SIGNATURE-----


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email