Help with warbler


#1

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

#2

Warbler has some … interesting issues around non-rails apps. If it’s
at all possible, you may want to try the most recent nightly builds of
GF v3, which should have merb auto-deploy support in them. If that’s not
possible, I remember that the merb wiki had a fairly good page on
deploying merb apps through warbler, now unfortunately only accessible
through the Google Cache
http://www.google.com/url?sa=t&source=web&ct=clnk&cd=10&url=http%3A%2F%2F209.85.173.104%2Fsearch%3Fq%3Dcache%3A8mRW3exN_3kJ%3Awiki.merbivore.com%2Fpages%2Fdeploying-a-merb-application-to-a-jee-container-us%3Fversion%3D22%2Bmerb%2Bwarbler%26hl%3Den%26ct%3Dclnk%26cd%3D10%26gl%3Dus%26client%3Dfirefox-a&ei=iWELSY2ZCImMsAOFuLiPDw&usg=AFQjCNGoFvLdr-dEthh-T67C3YZv510WIg&sig2=wkYlycCrA8SngzFUsrm_uQ


#3

On Fri, Oct 31, 2008 at 2:18 PM, Derek N. removed_email_address@domain.invalid
wrote:

You’re seeing this error because you use Rack::ShowStatus.
Any assistance is appreciated.
Hey Derek, thanks for the detailed report. The latest version of
warbler was released with Merb ~ 0.9.3 support (approximately). My
best guess is that the more recent Merb changes are causing the
problem – from the trace it looks like the application never gets
initialized properly, so it has nothing to dispatch to.

Can you try this trunk snapshot version of jruby-rack? You can either
configure java_libs like so:

config.java_libs.delete_if {|f| f =~ /jruby-rack/}
config.java_libs += ["/path/to/jruby-rack-0.9.3-SNAPSHOT.jar"]

or simply replace the jruby-rack-0.9.2.jar inside the warbler gem.

http://kenai.com/downloads/jruby-rack/jruby-rack-0.9.3-SNAPSHOT.jar

If you can let me know if that helps at all, that would be great, as
it would give me more incentive to get a new release out now that Merb
is nearing 1.0 status.

Thanks!
/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#4

Jacob;

Thanks for the response. I’ll take a look at GF3; Its features for
merb sound promising. Given the experiemental nature of the GF3
nightly builds it doesn’t seem like it is a viable option for a
production deployment currently.

Thanks again.

Best regards,
Derek

On Fri, Oct 31, 2008 at 4:07 PM, Jacob K. removed_email_address@domain.invalid
wrote:

likely something that I have missed.
abstract (1.0.0)
mime-types (1.15)

 [ADDED]  views/foo.html.erb

merb : worker (port 4000) ~ Successfully bound to port 4000

Loading init file from /Users/derek/jruby/testing/myapp/config/init.rb
a native gem (do_sqlite3) I quickly built my own “merb” gem that only
gem_plugin (0.2.3)
rake (0.8.3, 0.8.1)
Loading init file from /Users/derek/jruby/testing/myapp/config/init.rb
(only uncommented lines below)

mkdir -p tmp/war/WEB-INF/gems/specifications
cp
tmp/war/WEB-INF/gems/specifications/rspec-1.1.4.gemspec
/Users/derek/jruby/1.1.4/jruby-1.1.4/lib/ruby/gems/1.8/specifications/thor-0.9.8.gemspec
cp views/foo.html.erb tmp/war/WEB-INF/views/foo.html.erb

churns for a little while and then return a 500 error from Rack.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#5

On Fri, Oct 31, 2008 at 4:43 PM, Derek N. removed_email_address@domain.invalid
wrote:

Nick;

I grabbed the jruby-rack snapshot, added the java_libs to my
config/warble.rb, re-warbled the app, and deployed the new war to
Tomcat.

I am pleased to report that my simple Merb app is now working!

Awesome!

So when is the next release of jruby-rack? Or are the current
snapshots stable enough to use?

With JRuby 1.1.5 imminent, I can see a new combo Warbler/JRuby-Rack
release happening soon, perhaps next week during RubyConf.

Also, is there a way to direct warbler to not require the ‘merb’ gem?
When I run ‘warble config’ it seems to require the ‘merb’ gem. For
the projects I am working on I don’t need the full merb stack,
specifically the DataMapper components, and so am installing only the
merb gems that I need. It seems the current version of warbler looks
for the ‘merb’ gem even though it isn’t being used in the merb app.

I myself have not used Merb very much; I added auto-including the
“merb” gem to be similar to what Warbler does with Rails. But perhaps
all it should do is include “merb-core”? Would that be more inline
with Merb best practices?

Cheers,
/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#6

On Fri, Oct 31, 2008 at 5:10 PM, Nick S. removed_email_address@domain.invalid
wrote:

If you can let me know if that helps at all, that would be great, as
it would give me more incentive to get a new release out now that Merb
is nearing 1.0 status.

Nick;

I grabbed the jruby-rack snapshot, added the java_libs to my
config/warble.rb, re-warbled the app, and deployed the new war to
Tomcat.

I am pleased to report that my simple Merb app is now working!

Tomcat logs looking good:

Oct 31, 2008 5:26:29 PM org.apache.catalina.core.ApplicationContext log
INFO: D, [2008-10-31T17:26:29.981383 #1047] DEBUG – : Registering
Merb servlet adapter

Oct 31, 2008 5:26:29 PM org.apache.catalina.core.ApplicationContext log
INFO: D, [2008-10-31T17:26:29.994904 #1047] DEBUG – : Loading Merb
servlet sessions

Oct 31, 2008 5:26:30 PM org.apache.catalina.core.ApplicationContext log
INFO: D, [2008-10-31T17:26:30.024602 #1047] DEBUG – : Starting Merb

Oct 31, 2008 5:26:30 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Oct 31, 2008 5:26:30 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()

Thanks, Nick!

So when is the next release of jruby-rack? Or are the current
snapshots stable enough to use?

Also, is there a way to direct warbler to not require the ‘merb’ gem?
When I run ‘warble config’ it seems to require the ‘merb’ gem. For
the projects I am working on I don’t need the full merb stack,
specifically the DataMapper components, and so am installing only the
merb gems that I need. It seems the current version of warbler looks
for the ‘merb’ gem even though it isn’t being used in the merb app.

Great stuff! Thanks again.

Regards,
Derek


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#7

On Fri, Oct 31, 2008 at 6:11 PM, Nick S. removed_email_address@domain.invalid
wrote:

With JRuby 1.1.5 imminent, I can see a new combo Warbler/JRuby-Rack
release happening soon, perhaps next week during RubyConf.

Great!

I myself have not used Merb very much; I added auto-including the
“merb” gem to be similar to what Warbler does with Rails. But perhaps
all it should do is include “merb-core”? Would that be more inline
with Merb best practices?

I’m far from the best person to ask that, but a quick look at the gem
dependencies for a current install of the merb stack shows that all of
the gems depend either directly or indirectly on ‘merb-core’. It
would seem to be the reasonable choice to include. As far as I can
tell the ‘merb’ gem itself is only a simple means to pull in all the
dependencies for a “full stack” (core + extra goodies + orm) but
provides no further function.

Thanks again for your help.

Regards,
Derek


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#8

On Mon, Nov 24, 2008 at 8:37 PM, Derek N. removed_email_address@domain.invalid
wrote:

On Fri, Oct 31, 2008 at 5:11 PM, Nick S. removed_email_address@domain.invalid wrote:

With JRuby 1.1.5 imminent, I can see a new combo Warbler/JRuby-Rack
release happening soon, perhaps next week during RubyConf.

Hey Nick.

Any ETA on the next release of warbler/jruby-rack?

Hey Derek, thanks for the poke. Here’s my current plan:

  • Release new jruby-rack and activercord-jdbc soon (hopefully later
    today)
  • Release new Warbler after JRuby 1.1.6 hits in about a week.

Warbler itself doesn’t have too many changes, so you should be able
to upgrade to jruby 1.1.5 and jruby-rack inside warbler yourself.

Regards,
/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#9

On Fri, Oct 31, 2008 at 5:11 PM, Nick S. removed_email_address@domain.invalid
wrote:

With JRuby 1.1.5 imminent, I can see a new combo Warbler/JRuby-Rack
release happening soon, perhaps next week during RubyConf.

Hey Nick.

Any ETA on the next release of warbler/jruby-rack?

Thanks!

Derek


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email