Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 2. JRuby on Rails > Deploying Rails with jetty_rails - Pg. 47

Repackage your application with Warbler and deploy to Jetty. Jetty's JNDI module is not enabled in the standard webapps deployment folder by default, so either update $JETTY_HOME/etc/jetty.xml to enable JNDI for this directory or configure Jetty to use an alternative directory. It is the Jetty convention to install applications that require JNDI into the webapps-plus directory: $ copy MyKillerApplication.war $JETTY_HOME/webapps-plus Jetty supplies a convenient $JETTY_HOME/etc/jetty-plus.xml file, which configures Jetty to use that folder. Run this command from the Jetty home directory to start Jetty with JNDI support: $ java -server ­Xms512m ­Xmx1024m -XX:PermSize=256m ­XX:MaxPermSize=512m ­jar\ start.jar etc/jetty.xml etc/jetty-plus.xml See Also · Recipe 2.2, "Packaging Rails As a Java EE Web Application" · Recipe 2.5, "Packaging Rails with a JNDI DataSource" 2.9 Deploying Rails with jetty_rails Problem Many Rails developers today have never worked with the Java EE packaging process and launch their applications by navigating to the top level of their Rails project and starting one of two popular Ruby web servers: Mongrel or WEBrick. You want to run the Jetty application server with your Rails application but use a deployment method more familiar to Rails developers. Solution Use the jetty_rails gem, which allows you to run a Rails application with the Jetty server without performing any Java EE packaging. First, install the jetty_rails gem: jruby ­S gem install jetty_rails Then, go to the top of your Rails application and start the Jetty server: $ cd jrubycook_application $ jruby -S jetty_rails Discussion You can get a list of some common startup parameters by running this command: jruby ­S jetty_rails --help The port and environment options are common startup parameters used in the Mongrel and WEBrick HTTP servers: 2.9 Deploying Rails with jetty_rails | 47