org.jruby.rack.RackInitializationException: can't convert nil into String

Hi all,

I have spent most of my time lately moving a mri ruby rack app to jruby.
I
have produced a war manually (I could not use warbler because bundler
does
not support the “:path =>” option in gem instruction) with the following
web.xml file:

jruby.compat.version 1.9 gem.path /WEB-INF/gems RackFilter org.jruby.rack.RackFilter RackFilter /*

org.jruby.rack.RackServletContextListener

But when I start Tomcat, I get this error :

org.jruby.rack.RackInitializationException: can’t convert nil into
String
from
file:/var/lib/tomcat6/webapps/mtm_trainer/WEB-INF/lib/jruby-stdlib-1.6.5.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
require' from /var/lib/tomcat6/webapps/mtm_trainer/WEB-INF/./mtm_trainer.rb:3:in(root)’
from org/jruby/RubyKernel.java:1047:in require' from file:/var/lib/tomcat6/webapps/mtm_trainer/WEB-INF/lib/jruby-stdlib-1.6.5.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:inrequire’
from
/var/lib/tomcat6/webapps/mtm_trainer/WEB-INF/./mtm_trainer.rb:22:in
(root)' from org/jruby/RubyBasicObject.java:1720:ininstance_eval’
from
file:/var/lib/tomcat6/webapps/mtm_trainer/WEB-INF/lib/jruby-rack-1.0.10.jar!/vendor/rack-1.3.2/rack/builder.rb:51:in
initialize' from /var/lib/tomcat6/webapps/mtm_trainer/WEB-INF/config.ru:1:in(root)’

at

org.jruby.rack.DefaultRackApplicationFactory$4.init(DefaultRackApplicationFactory.java:204)
at
org.jruby.rack.DefaultRackApplicationFactory.getApplication(DefaultRackApplicationFactory.java:54)
at
org.jruby.rack.SharedRackApplicationFactory.init(SharedRackApplicationFactory.java:27)
… 25 more
Caused by: org.jruby.exceptions.RaiseException: (TypeError) can’t
convert
nil into String

According to the stack trace, I suspect that the 1.8 ruby interpeter is
loaded instead of the 1.9, but I don’t understand why. Am I doing
something
wrong ?

Thanks in advance for any help !

Damien

On Nov 7, 2011, at 10:11 AM, Damien Cram wrote:

Hi all,

I have spent most of my time lately moving a mri ruby rack app to jruby. I have
produced a war manually (I could not use warbler because bundler does not support
the “:path =>” option in gem instruction) with the following web.xml file:

Not the answer you’re looking for but I’m curious why being able to use
the :path option inside a WAR deployment is a requirement. A WAR is
typically meant to be a self contained, deployable entity. Rolling your
own replacement for Warbler for that purpose sounds suspect to me. We
use the :path option to reference local copies of our internal gems in
development but that all gets fixed up (i.e. dependent gems are built,
installed, and updated) before deploying.

-lenny

This is what I get from gemjar:

$ warble gemjar
warning: Bundler path' components are not currently supported. The myt_classify0.2.0’ component was not bundled.
Your application may fail to boot!

Here is my Gemfile:

source :rubygems
gem ‘sinatra’, ‘>= 1.3.0’
gem ‘myt_classify’, ‘=0.2.0’, :path => ‘…/myt_classify/’

When I look at the packaged gems in my war, my own gem myt_classify is
not
present as announced by warbler. How do you make your own gems packaged
into your war ?

Damien

2011/11/7 Lenny M. [email protected]

<param-value>/WEB-INF/gems</param-value>
from from org/jruby/RubyBasicObject.java:1720:in `instance_eval' at Thanks in advance for any help !

Damien


Damien Cram

Pilotez vos actions sur les rseaux sociaux

13 rue Saint-Sauveur - 75002 Paris - France
+33 (0)1 82 09 70 15 / +33 (0)6 72 64 07 30

http://goog_1111776082[email protected]
www.mytwatch.com
@myTwiNet http://twitter.com/myTwiNet

just a thought. install your gem locally and allow bundler to use system
gems. then it should work or did I miss something ?

regards,
Kristian

ok, I also do not install gem on system level (that only the package of
OS
should do IMO). there are some ways to do this I think:

you can set your $HOME/.gemrc
install: --user-install
update: --user-install

which install the gems somewhere in $HOME/.gem

OR use rvm which can be configured to have a per project repository for
your gems.

OR I use the (ruby-)maven to install gems, jar and create war files
which
uses per default a per project repository and works sufficiently
seamless
with bundler

  • Kristian

I would like to try, but I realize that I have no idea how to tell
bundler
to use system gems.

I will take it if it works, but I don’t really like the idea of
installing
my development gems to my system.

Regards

2011/11/7 kristian [email protected]

2011/11/7 Lenny M. [email protected]

<param-name>gem.path</param-name>

org.jruby.rack.RackInitializationException: can’t convert nil into
from
at
wrong ?

www.mytwatch.com
@myTwiNet http://twitter.com/myTwiNet


Damien Cram

Pilotez vos actions sur les rseaux sociaux

13 rue Saint-Sauveur - 75002 Paris - France
+33 (0)1 82 09 70 15 / +33 (0)6 72 64 07 30

http://goog_1111776082[email protected]
www.mytwatch.com
@myTwiNet http://twitter.com/myTwiNet

so did you install your gem? something like:

cd myt_classify
gem build
gem install -l myt_classify.gem

bundler will use it.

  • Kristian

On Mon, Nov 7, 2011 at 10:08 AM, Lenny M. [email protected] wrote:

Not the answer you’re looking for but I’m curious why being able to use the
:path option inside a WAR deployment is a requirement. A WAR is typically
meant to be a self contained, deployable entity. Rolling your own
replacement for Warbler for that purpose sounds suspect to me. We use the
:path option to reference local copies of our internal gems in development
but that all gets fixed up(i.e. dependent gems are built, installed, and
updated)before deploying.
-lenny

Yeah, the way Bundler works now to look up :path-based gems it’s not
possible to bundle them in a war file unless you want to make extra
legwork for yourself to create the exact same path on the server where
the war is deployed with the gem contents.

An easy way around this is to change the gem to a :git-based gem, and
point to your git repository for the gem source. (Don’t use git? You
can simply create a repository using git init in your gem
directory.)

/Nick

I use rvm to install my gems, so they are installed in
“/home/damien/.rvm/gems/jruby-1.6.5/gems”, but how do I tell bundler to
use
them as the source for my bundle install ? That was your suggestion,
right ?

How am I supposed to package (i.e. build and install to WEB-INF/gems at
war
creation time) my development gems into the war with warble ?

Regards,
Damien

2011/11/7 kristian [email protected]

your gems.

bundler to use system gems.

gems. then it should work or did I miss something ?

warning: Bundler `path’ components are not currently supported.
When I look at the packaged gems in my war, my own gem myt_classify is

Not the answer you’re looking for but I’m curious why being able to

<!DOCTYPE web-app PUBLIC
from
from org/jruby/RubyBasicObject.java:1720:in `instance_eval'
at

Thanks in advance for any help !

13 rue Saint-Sauveur - 75002 Paris - France
+33 (0)1 82 09 70 15 / +33 (0)6 72 64 07 30

http://goog_1111776082[email protected]
www.mytwatch.com
@myTwiNet http://twitter.com/myTwiNet


Damien Cram

Pilotez vos actions sur les rseaux sociaux

13 rue Saint-Sauveur - 75002 Paris - France
+33 (0)1 82 09 70 15 / +33 (0)6 72 64 07 30

http://goog_1111776082[email protected]
www.mytwatch.com
@myTwiNet http://twitter.com/myTwiNet

Thank you Nick. Is “:git” option supposed to work with local
repositories
that are not published on github ? I did a “git init” in my gem dir but
I
got :

$warble
warble aborted!
…/myt_classify/ (at master) is not checked out. Please run bundle install

The “bundle install” give:

$bundle install
Updating …/myt_classify/
fatal: ‘…/myt_classify’ does not appear to be a git repository
fatal: The remote end hung up unexpectedly
Git error: command git fetch --force --quiet --tags '../myt_classify/' "refs/heads/*:refs/heads/*" in directory
/home/damien/dev/ws-myt/mtm/mtm_trainer/tst/jruby/1.9/cache/bundler/git/myt_classify-1b652aaa23e6b89680cb1e09a133a77f3fc6bf12
has failed.
If this error persists you could try removing the cache directory
‘/home/damien/dev/ws-myt/mtm/mtm_trainer/tst/jruby/1.9/cache/bundler/git/myt_classify-1b652aaa23e6b89680cb1e09a133a77f3fc6bf12’

My Gemfile is:

source :rubygems
gem ‘sinatra’, ‘>= 1.3.0’
gem ‘myt_classify’, :git => ‘…/myt_classify/’

I also tried to publish my own gems to a local gem server and to modify
my
Gemfile:

source :rubygems
gem ‘sinatra’, ‘>= 1.3.0’
source ‘http://localhost/gems/
gem ‘myt_classify’, ‘=0.2.0’

And I got the command “bundle install” work fine but “warble” says:

warble aborted!
Could not find gem ‘myt_classify (= 0.2.0) java’ in any of the gem
sources
listed in your Gemfile.

So far, I have to admit that I have not found a way to make warble
produce
my war. I spent sometimes producing it by hand, but the war app won’t
run
in Tomcat sometimes (cf. my first initial email).

2011/11/7 Nick S. [email protected]

not support the “:path =>” option in gem instruction) with the following
updated) before deploying.
directory.)

/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Damien Cram

Pilotez vos actions sur les rseaux sociaux

13 rue Saint-Sauveur - 75002 Paris - France
+33 (0)1 82 09 70 15 / +33 (0)6 72 64 07 30

http://goog_1111776082[email protected]
www.mytwatch.com
@myTwiNet http://twitter.com/myTwiNet

On Nov 7, 2011, at 12:32 PM, Damien Cram wrote:

gem ‘sinatra’, ‘>= 1.3.0’
gem ‘myt_classify’, ‘=0.2.0’, :path => ‘…/myt_classify/’

When I look at the packaged gems in my war, my own gem myt_classify is not
present as announced by warbler. How do you make your own gems packaged into your
war ?

Forgive the contrived example but let’s say MyApp1 and MyApp2 are two
rails apps at Acme. Both apps share a lot of acme domain code (e.g.
models, etc…) so I’ve moved that stuff into a separate gem to be
shared. The Gemfiles looks something like:

source :gemcutter

source “http://rubygems.acme.com


gem ‘acme’

There are a few options here for getting things set up so that my
acme-x.x.x.gem is found when I ‘bundle install’. An internal gem server
(e.g. rubygems.acme.com), an exportable/importable rvm gemset, or
perhaps the simplest option, using ‘bundle package’ and copying
acme-1.0.x.gem into the vendor/cache directory before building the
WAR**.

** Note - We do something similar and currently check vendor/cache into
revision control. This is nice because anybody can check out the app and
install the bundle easily. The downside is that it can rapidly increase
the size of your source code repository as you update dependencies. In
hind site, I would actually avoid checking gems into version control.

Now if I’ve made some changes in the acme gem that I would like to see
immediately in MyApp1(i.e. with a browser refresh) without having to
rebuild and re-install the gem, I can temporarily modify my Gemfile…

gem ‘acme’, :path => ‘…/acme’

‘bundle install’ and I’m good to go. Eventually when I’m ready to deploy
my changes for others to see (deploy the WAR), it’s time to bump the
version number of my gem, build it, and install it. Once the gem has
been updated, I can revert/comment out the :path usage in the MyApp1
Gemfile, ‘bundle update acme’, and build my war. When building the war,
I’ll typically do ‘bundle install --deployment’ first. As long as the
acme gem is found either in vendor/cache, one of my ‘sources’ declared
in the Gemfile, or in my $GEM_HOME, bundler is happy.

That’s more or less what we’re doing. Hope it helps.

-lenny

Whoops. Forgot to mention that you’ll need to “git add” all the files
and “git commit” to create at least one revision in the repository. Then
try again. It should not matter that you don’t have the git repository
cloned somewhere else on a server.

/Nick

Thank you Lenny. That is typically the kind of solution that I need.
After
trying what you said (copying my own gem to vendor/cache), it appears
that
that the trick works fine with bundler but not with warbler.

Say my Gemfile is :

source :rubygems
gem ‘sinatra’
gem ‘myt_classify’

with ‘myt_classify-0.2.0.gem’ beind added manually in ‘vendor/cache’, I
can
run “bundle install” and myt_classify will be found as expected. But
when
it comes to warble :

$ warble
warble aborted!
Could not find myt_classify-0.2.0 in any of the sources

Warbler found “myt_classify” in “vendor/cache” (otherwise it could not
known the current version “0.2.0”) but also needs to be accessible from
one
valid Bundler source. I built my own local Rubygems server and modified
my
Gemfile accordingly:

source :rubygems
gem ‘sinatra’, ‘>= 1.3.0’
source “http://localhost/gems/
gem ‘myt_classify’

Once again, “bundle install” works like a charm and can find
myt_classify
on my local gem server (my vendor/cache was emptied to make that sure),
but
Warbler says invariably :

$ warble
warble aborted!
Could not find gem ‘myt_classify (>= 0) java’ in any of the gem sources
listed in your Gemfile.

Does Warbler just not like me or am I doing something wrong ?

Damien

2011/11/8 Lenny M. [email protected]

Here is my Gemfile:

site, I would actually avoid checking gems into version control.
updated, I can revert/comment out the :path usage in the MyApp1 Gemfile,

Hi all,
replacement for Warbler for that purpose sounds suspect to me. We use the

org.jruby.rack.RackFilter

/var/lib/tomcat6/webapps/mtm_trainer/WEB-INF/./mtm_trainer.rb:3:in `(root)’
from /var/lib/tomcat6/webapps/mtm_trainer/WEB-INF/config.ru:1:in
nil into String

13 rue Saint-Sauveur - 75002 Paris - France
+33 (0)1 82 09 70 15 / +33 (0)6 72 64 07 30

http://goog_1111776082/[email protected]
www.mytwatch.com
@myTwiNet http://twitter.com/myTwiNet


Damien Cram

Pilotez vos actions sur les rseaux sociaux

13 rue Saint-Sauveur - 75002 Paris - France
+33 (0)1 82 09 70 15 / +33 (0)6 72 64 07 30

http://goog_1111776082[email protected]
www.mytwatch.com
@myTwiNet http://twitter.com/myTwiNet

Well, my problem was that I did not execute warble after “bundle exec”.
It
works much better now, thx Lenny ! I am a beginner to ruby and jruby. I
did
not get the complete purpose of Bundler and was not using it the right
way.

Thank you all for your help.

2011/11/9 Lenny M. [email protected]

gem ‘sinatra’
Warbler found “myt_classify” in “vendor/cache” (otherwise it could not
on my local gem server (my vendor/cache was emptied to make that sure), but
Hmm… I have no trouble building a .war with gems present only in
warbler-1.3.2, bundler-1.0.21

On Nov 7, 2011, at 12:32 PM, Damien Cram wrote:
source :rubygems
rails apps at Acme. Both apps share a lot of acme domain code (e.g. models,
acme-x.x.x.gem is found when I ‘bundle install’. An internal gem server
Now if I’ve made some changes in the acme gem that I would like to see
typically do ‘bundle install --deployment’ first. As long as the acme gem

I have spent most of my time lately moving a mri ruby rack app to jruby.
but that all gets fixed up (i.e. dependent gems are built, installed, and
jruby.compat.version

from org/jruby/RubyKernel.java:1047:in `require'

`(root)’

13 rue Saint-Sauveur - 75002 Paris - France

www.mytwatch.com
@myTwiNet http://twitter.com/myTwiNet


Damien Cram

Pilotez vos actions sur les rseaux sociaux

13 rue Saint-Sauveur - 75002 Paris - France
+33 (0)1 82 09 70 15 / +33 (0)6 72 64 07 30

http://goog_1111776082[email protected]
www.mytwatch.com
@myTwiNet http://twitter.com/myTwiNet

On Nov 9, 2011, at 6:35 AM, Damien Cram wrote:

$ warble
Once again, “bundle install” works like a charm and can find myt_classify on my
local gem server (my vendor/cache was emptied to make that sure), but Warbler says
invariably :

$ warble
warble aborted!
Could not find gem ‘myt_classify (>= 0) java’ in any of the gem sources listed
in your Gemfile.

Does Warbler just not like me or am I doing something wrong ?

Hmm… I have no trouble building a .war with gems present only in
vendor/cache and no local gem server.

  • Did you try running warbler after running ‘bundle install
    –deployment’? I had problems at one point with bundler itself not being
    packaged correctly into the war(an incomplete .gemspec file) without
    that.
  • What versions of Warbler, RubyGems, Bundler?? I also had problems at
    one point with older/incompatible versions of RubyGems.
  • Are you running warbler with bundle exec? ‘bundle exec warble’

I’m currently using Jruby 1.6.2, RubyGems 1.8.5, warbler-1.3.2,
bundler-1.0.21

-lenny

On Nov 9, 2011, at 5:13 PM, Damien Cram wrote:

Well, my problem was that I did not execute warble after “bundle exec”. It works
much better now, thx Lenny ! I am a beginner to ruby and jruby. I did not get the
complete purpose of Bundler and was not using it the right way.

Thank you all for your help.

Glad to help. I found this post very helpful when I was first trying to
wrap my head around Bundler.