Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to compile a Rails app to a Java VM JAR file?

Essentially the only thing I can deploy to my deployment machine is a JAR file. I can't install JRuby, nor can I install Glassfish or Tomcat.

Is it possible to package up a Rails application (including Rails, vendored, of course) to a JAR file such that I can do

c:\my_server> java rails_app.jar

and have it run WEBRick or Mongrel within the JVM?

like image 720
James A. Rosen Avatar asked Sep 24 '08 18:09

James A. Rosen


2 Answers

I wrote an article a year ago about how to embed your ruby sources with jruby and everything else you want into one jar file, and then run it with "java -jar myapp.jar".

It will need some work to make it boot rails I guess, but it should not be too hard. And with the complimentary jruby documentation on their wiki, i guess you can run a jetty+war thing fairly easily with this technique.

The article is here: http://blog.kesor.net/2007/08/14/jruby-in-a-jar/

like image 60
Evgeny Avatar answered Nov 15 '22 15:11

Evgeny


I'd recommend that you checkout Jetty. The process for Embedding Jetty is surprisingly easy, and it should be possible to give it your servlets from your current jar file. I haven't used Ruby/Rails, though, so I'm not sure if there are any complications there.

Is it normally possible to embed all of your rails templates/models into a jar inside of a war file for deployment on Tomcat? If so, then you should be able to get embedded Jetty to pull it from your single jar as well.

like image 45
jsight Avatar answered Nov 15 '22 17:11

jsight