Error loading cookbook sample on Rack


I am trying to dpeloy a WAR file created using warbler 0.9.9 (with Rack)
deploy it on GlassFish. The application comes up fine but in the server
error message is logged saying it can not find certain files:

Processing CategoriesController#index (for at 2008-05-29
Session ID: 980b1193c95a111af30b05c0d22a55af
Parameters: {“controller”=>“categories”, “action”=>“index”}
Rendering template within layouts/application
Rendering categories/index
Completed in 0.02200 (45 reqs/sec) | Rendering: 0.01700 (77%) | DB:
(0%) | 200 OK [http://localhost/cookbook/categories]

WebModule[/cookbook] ServletContext.log():

Processing ApplicationController#index (for at 2008-05-29
13:39:38) [GET]
Session ID: 4a550b446fdb0bd2a976d92d67ccefca
Parameters: {}

ActionController::RoutingError (No route matches
“/stylesheets/application.css” with {:method=>:get}):
recognize_path' /gems/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1424:inrecognize’
handle_request' /gems/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:indispatch’
dispatch_cgi' /gems/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:indispatch’







Inside the war file there is layout.erb as part of actionpack gem. Any
whats going on here?


On May 29, 2008, at 4:41 PM, Vivek P. wrote:

WebModule[/cookbook] ServletContext.log():

It looks like your app is mounted at the “/cookbook” context root,

ActionController::RoutingError (No route matches “/stylesheets/
application.css” with {:method=>:get}):

…your stylesheet link is to “/stylesheets/application.css”. This is
a common problem with running Rails and Merb in a servlet container.
Out of the box, both Rails and Merb expect that all urls are relative
to the root “/” path, but servlet-based apps usually expect to have a
context root prefix, like “/cookbook”.
I’m not too familiar with Rails anymore, so I can’t tell you exactly
how to fix it, but there should be a setting that you can change to
make Rails generate urls relative to your context root. It used to be
a constant called RAILS_RELATIVE_URL_ROOT (or something like that),
but I think it has a prettier name now.


To unsubscribe from this list, please visit:


The change that needs to happen is in config/environments/production.rb:

config.action_controller.asset_host = “/cookbook”

adding the above line takes care of it.

Although warbler should take care of it as for most of the servlet
containers, the war file name goes as the root context of the web
application. Although it brings the question of what if someone deploys
war file and tell the container to deploy it at context root!

Still I think there should be an easy way to take care of it otherwise
anyone using warbler has to make sure modifying the production.rb.