herokujrubyjrubyonrails

How to deploy JRuby Rails 3.1.x on Heroku?


I want to be able to deply a jruby rails 3.1 app to Heroku.

Heroku now suports Java: http://blog.heroku.com/archives/2011/08/25/java/ Supposedly, it should be possible to deploy a JRuby rails application. There's a tutorial here for plain java: http://devcenter.heroku.com/articles/java and another here: http://devcenter.heroku.com/articles/spring-mvc-hibernate

Here's a tutorial for a JRuby Sinatra app on Heroku: http://chris.chowie.net/2011/08/28/Sinatra-with-JRuby-on-Heroku/ In order to get this to work, I had use non-jruby ruby when running heroku, as heroku crashes if rvm uses jruby.

In order to run the command

mvn package

I had to run this:

bundle --gemfile=/home/justin/github/sinatra-jruby-heroku/Jemfile install temple
bundle --gemfile=/home/justin/github/sinatra-jruby-heroku/Jemfile update

I created the app:

heroku create jg1-sinatra --stack cedar

I pushed the file to heroku, but when the app started, it crashed. :(

Any advice? I'm guessing that it won't be long before Heroku has a tutorial on this.

Log file from Heroku:

2011-11-21T08:30:40+00:00 heroku[slugc]: Slug compilation started
2011-11-21T08:31:17+00:00 heroku[api]: Deploy 3bccec5 by justin.gordon@gmail.com
2011-11-21T08:31:17+00:00 heroku[api]: Release v7 created by justin.gordon@gmail.com
2011-11-21T08:31:18+00:00 heroku[web.1]: State changed from crashed to created
2011-11-21T08:31:18+00:00 heroku[slugc]: Slug compilation finished
2011-11-21T08:31:20+00:00 heroku[web.1]: Starting process with command `sh script/jruby -S trinidad -p 17687`
2011-11-21T08:31:20+00:00 app[web.1]: Classpath is: :/app/etc:/.m2/repository/org/jruby/jruby-complete/1.6.3/jruby-complete-1.6.3.jar
2011-11-21T08:31:20+00:00 app[web.1]: Exception in thread "main" java.lang.NoClassDefFoundError: org/jruby/Main
2011-11-21T08:31:20+00:00 app[web.1]: Caused by: java.lang.ClassNotFoundException: org.jruby.Main
2011-11-21T08:31:20+00:00 app[web.1]:   at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
2011-11-21T08:31:20+00:00 app[web.1]:   at java.security.AccessController.doPrivileged(Native Method)
2011-11-21T08:31:20+00:00 app[web.1]:   at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
2011-11-21T08:31:20+00:00 app[web.1]:   at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
2011-11-21T08:31:20+00:00 app[web.1]:   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
2011-11-21T08:31:20+00:00 app[web.1]:   at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
2011-11-21T08:31:20+00:00 app[web.1]: Could not find the main class: org.jruby.Main. Program will exit.
2011-11-21T08:31:20+00:00 heroku[web.1]: Process exited
2011-11-21T08:31:21+00:00 heroku[web.1]: State changed from starting to crashed

Solution

  • You have this line :

    Classpath is: :/app/etc:/.m2/repository/org/jruby/jruby-complete/1.6.3/jruby-complete-1.6.3.jar
    

    Seams you have reference to your locale repository somewhere and Heroku of corse don't have it. I dunno so much about packaging, but may be this reference appear here ?

    Check all ref and see packaging options could be a good start ...