I’m looking for assistance in using warbler to package a simple merb
app. As I am new to JRuby and Merb, and Java in general, it’s very
likely something that I have missed.
I’m using jruby 1.1.4 on Mac OSX 10.5.5 with Java 6.
I’ve successfully installed the latest (0.9.12) merb-core and merb-gen
gems and their dependencies, mongrel, and warbler.
$ jruby -S gem li
*** LOCAL GEMS ***
abstract (1.0.0)
diff-lcs (1.1.2)
erubis (2.6.2)
extlib (0.9.8)
gem_plugin (0.2.3)
highline (1.4.0)
hpricot (0.6.164)
jruby-openssl (0.3)
json_pure (1.1.3)
merb-core (0.9.12)
merb-gen (0.9.12)
mime-types (1.15)
mongrel (1.1.5)
rack (0.4.0)
rake (0.8.3, 0.8.1)
rspec (1.1.4)
sources (0.0.1)
templater (0.3.3)
thor (0.9.8)
warbler (0.9.11)
I created a merb application structure using merb-gen.
$ jruby -S merb-gen flat --orm none myapp
Generating with flat generator:
[ADDED] gems
[ADDED] merb.thor
[ADDED] .gitignore
[ADDED] README.txt
[ADDED] Rakefile
[ADDED] application.rb
[ADDED] config/framework.rb
[ADDED] config/init.rb
[ADDED] views/foo.html.erb
[ADDED] spec
The “flat” template creates a simple merb app that runs
out-of-the-box. Fire up merb to launch the mongrel to serve the app,
browse to http://localhost:4000 and all looks good.
$ jruby -S merb
Loading init file from /Users/derek/jruby/testing/myapp/config/init.rb
merb : worker (port 4000) ~ Starting Mongrel at port 4000
merb : worker (port 4000) ~ Successfully bound to port 4000
merb : worker (port 4000) ~ Started request handling: Fri Oct 31
13:52:49 -0400 2008
merb : worker (port 4000) ~ Routed to: {“controller”=>“myapp”,
“action”=>“index”}
merb : worker (port 4000) ~ Params: {“controller”=>“myapp”,
“action”=>“index”}
merb : worker (port 4000) ~ {:before_filters_time=>0.000225,
:after_filters_time=>0.000174, :action_time=>0.002743,
:dispatch_time=>0.006714}
merb : worker (port 4000) ~
^Cmerb : worker (port 4000) ~ Reaping Workers
Looks good. Now try to bundle it into a war to deploy.
Attempting to use ‘warble config’ causes an error stating it needs the
“merb” gem.
$ jruby -S warble config
Loading init file from /Users/derek/jruby/testing/myapp/config/init.rb
Loading init file from /Users/derek/jruby/testing/myapp/config/init.rb
rake aborted!
gem ‘merb (= 0.9.12, runtime)’ not installed
/Users/derek/jruby/1.1.4/jruby-1.1.4/lib/ruby/gems/1.8/gems/warbler-0.9.11/lib/warbler/task.rb:257:in
`define_single_gem_tasks’
(See full trace by running task with --trace)
Something in warble assumes it needs the “merb” gem. Since the
current 0.9.12 release of the default merb stack has a dependecy upon
a native gem (do_sqlite3) I quickly built my own “merb” gem that only
has “merb-core” as a dependency and installed that.
$ jruby -S gem li
*** LOCAL GEMS ***
abstract (1.0.0)
diff-lcs (1.1.2)
erubis (2.6.2)
extlib (0.9.8)
gem_plugin (0.2.3)
highline (1.4.0)
hpricot (0.6.164)
jruby-openssl (0.3)
json_pure (1.1.3)
merb (0.9.12)
merb-core (0.9.12)
merb-gen (0.9.12)
mime-types (1.15)
mongrel (1.1.5)
rack (0.4.0)
rake (0.8.3, 0.8.1)
rspec (1.1.4)
sources (0.0.1)
templater (0.3.3)
thor (0.9.8)
warbler (0.9.11)
Now ‘warble config’ executes OKay.
$ jruby -S warble config --trace
Loading init file from /Users/derek/jruby/testing/myapp/config/init.rb
Loading init file from /Users/derek/jruby/testing/myapp/config/init.rb
** Invoke config (first_time)
** Execute config
cp
/Users/derek/jruby/1.1.4/jruby-1.1.4/lib/ruby/gems/1.8/gems/warbler-0.9.11/generators/warble/templates/warble.rb
config/warble.rb
I edit the config/warble.rb as I think is appropriate.
(only uncommented lines below)
Warbler::Config.new do |config|
config.dirs = %w(config gems log spec views)
config.includes = FileList[“application.rb”]
config.gems = [“merb-core”]
config.gem_dependencies = true
config.webxml.booter = :merb
end
In config/init.rb I add to the Merb::Config block to set path_prefix.
c[:path_prefix] = ‘/myapp’,
I then warble the app into a war.
$ jruby -S warble
Loading init file from /Users/derek/jruby/testing/myapp/config/init.rb
Loading init file from /Users/derek/jruby/testing/myapp/config/init.rb
mkdir -p tmp/war/WEB-INF/gems/specifications
cp
/Users/derek/jruby/1.1.4/jruby-1.1.4/lib/ruby/gems/1.8/specifications/merb-core-0.9.12.gemspec
tmp/war/WEB-INF/gems/specifications/merb-core-0.9.12.gemspec
mkdir -p tmp/war/WEB-INF/gems/gems
cp
/Users/derek/jruby/1.1.4/jruby-1.1.4/lib/ruby/gems/1.8/specifications/extlib-0.9.8.gemspec
tmp/war/WEB-INF/gems/specifications/extlib-0.9.8.gemspec
cp
/Users/derek/jruby/1.1.4/jruby-1.1.4/lib/ruby/gems/1.8/specifications/erubis-2.6.2.gemspec
tmp/war/WEB-INF/gems/specifications/erubis-2.6.2.gemspec
cp
/Users/derek/jruby/1.1.4/jruby-1.1.4/lib/ruby/gems/1.8/specifications/abstract-1.0.0.gemspec
tmp/war/WEB-INF/gems/specifications/abstract-1.0.0.gemspec
cp
/Users/derek/jruby/1.1.4/jruby-1.1.4/lib/ruby/gems/1.8/specifications/rake-0.8.3.gemspec
tmp/war/WEB-INF/gems/specifications/rake-0.8.3.gemspec
cp
/Users/derek/jruby/1.1.4/jruby-1.1.4/lib/ruby/gems/1.8/specifications/json_pure-1.1.3.gemspec
tmp/war/WEB-INF/gems/specifications/json_pure-1.1.3.gemspec
cp
/Users/derek/jruby/1.1.4/jruby-1.1.4/lib/ruby/gems/1.8/specifications/rspec-1.1.4.gemspec
tmp/war/WEB-INF/gems/specifications/rspec-1.1.4.gemspec
cp
/Users/derek/jruby/1.1.4/jruby-1.1.4/lib/ruby/gems/1.8/specifications/rack-0.4.0.gemspec
tmp/war/WEB-INF/gems/specifications/rack-0.4.0.gemspec
cp
/Users/derek/jruby/1.1.4/jruby-1.1.4/lib/ruby/gems/1.8/specifications/mime-types-1.15.gemspec
tmp/war/WEB-INF/gems/specifications/mime-types-1.15.gemspec
cp
/Users/derek/jruby/1.1.4/jruby-1.1.4/lib/ruby/gems/1.8/specifications/hpricot-0.6.164-java.gemspec
tmp/war/WEB-INF/gems/specifications/hpricot-0.6.164-java.gemspec
cp
/Users/derek/jruby/1.1.4/jruby-1.1.4/lib/ruby/gems/1.8/specifications/thor-0.9.8.gemspec
tmp/war/WEB-INF/gems/specifications/thor-0.9.8.gemspec
mkdir -p tmp/war/WEB-INF/config
mkdir -p tmp/war/WEB-INF/log
mkdir -p tmp/war/WEB-INF/spec
mkdir -p tmp/war/WEB-INF/views
cp config/framework.rb tmp/war/WEB-INF/config/framework.rb
cp config/init.rb tmp/war/WEB-INF/config/init.rb
cp config/warble.rb tmp/war/WEB-INF/config/warble.rb
cp log/merb.main.pid tmp/war/WEB-INF/log/merb.main.pid
cp spec/spec_helper.rb tmp/war/WEB-INF/spec/spec_helper.rb
cp views/foo.html.erb tmp/war/WEB-INF/views/foo.html.erb
cp application.rb tmp/war/WEB-INF/application.rb
mkdir -p tmp/war/WEB-INF/lib
cp
/Users/derek/jruby/1.1.4/jruby-1.1.4/lib/ruby/gems/1.8/gems/warbler-0.9.11/lib/jruby-complete-1.1.4.jar
tmp/war/WEB-INF/lib/jruby-complete-1.1.4.jar
cp
/Users/derek/jruby/1.1.4/jruby-1.1.4/lib/ruby/gems/1.8/gems/warbler-0.9.11/lib/jruby-rack-0.9.2.jar
tmp/war/WEB-INF/lib/jruby-rack-0.9.2.jar
mkdir -p tmp/war/WEB-INF
As far as I can tell all the parts needed are bundled into the myapp.war
file.
I then deploy the war by copying it into a fresh install of Apache
Tomcat.
$ cp myapp.war /Users/derek/Downloads/tc6/apache-tomcat-6.0.18/webapps/
I start Tomcat and browse to http://localhost:8080 and see the default
Tomcat welcome page. I then try http://localhost:8080/myapp and it
churns for a little while and then return a 500 error from Rack.
Internal Server Error (500)
Request Method: GET
Request URL: http://localhost:8080/myapp//500.html
Internal Server Error
You’re seeing this error because you use Rack::ShowStatus.
Tomcat logs show a java.lang.NullPointerException in
DefaultRackDispatcher.
http://pastie.org/305132
Just in case it is a Tomcat issue I tried Glassfish2, but I get the
same NullPointer problem.
I also tried running Tomcat with JAVA_OPTS=“-server -Xmx512m -Xms512m
-XX:PermSize=256m -XX:MaxPermSize=512m” but with the same results.
Any assistance is appreciated.
Thanks,
Derek
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email