Jump to content

How to package a Ruby on Rails application for Java EE

+ 1
  mike-loukides's Photo
Posted Oct 26 2009 11:44 AM

Use the Warbler gem. From the JRuby Cookbook:

Use Warbler to package your Rails application as a WAR file. Start by installing the gem:

$ jruby –S gem install warbler

This gem adds the warble command, which allows you to create, configure, and clean up the WAR file. All Warbler commands should be executed in the root directory of your Rails application. Start by creating a Warbler configuration file with this command:

$ jruby –S warble config

The new configuration file is written to config/warble.rb. This file allows you to set most of the necessary options for building your WAR and determining how Rails will run in the web container. Open warble.rb and configure config.webxml.rails.env to the environment of your Rails deployment. Next, add all the gems used by your web application to the config.gems hash except for the rails gem. Rails is included in the default hash. Here is a warble.rb file showing these options:

# Value of RAILS_ENV for the webapp
config.webxml.rails.env = 'development'

# List of all your application's gems
config.gems << "activerecord-jdbcmysql-adapter"
config.gems << "jruby-openssl"

You're ready to create a WAR file by running this command:

$ jruby –S warble war

This generates a WAR file named the Rails project home directory name by default. For example, if our Rails project was in the MyKillerApplication folder, the WAR file would be named MyKillerApplication.war. This WAR file can then be deployed into your Java EE container using the container's deployment process.

JRuby Cookbook

Learn more about this topic from JRuby Cookbook.

This Cookbook offers practical solutions for using the JRuby, the Java implementation of the Ruby language. Targeted recipes help you deploy Rails web applications on Java servers, integrate JRuby code with Java technologies, develop JRuby desktop applications with Java toolkits, and more. Using numerous reusable code samples, JRuby Cookbook demonstrates how you can take advantage of JRuby's potential.

See what you'll learn

0 Subscribe

0 Replies