论坛首页 编程语言技术论坛

Run Rails app on Tomcat Successfully

浏览 4417 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2007-05-22  

Package up Rails app as WAR file & Run it on Tomcat Successfully

            
             (please excuse me for writing in English, for there's no input method installed on client's machine)
  • This short HOW-TO includes 9 steps. Basically, you need to install two adapters in your Rails application to support WAR package.

1. Get your Rails application running in production mode.

  • This is because the plugin that will be used to generate the war file only works in production mode.

2. Install plugin GoldSpike by executing

  • $ script/plugin install svn://rubyforge.org/var/svn/jruby-extras/trunk/rails-integration/plugins/goldspike

  • NOTE: This is the adapter for input of your Rails application.

3. Install gem package activerecord-jdbc by executing

  • $ gem install activerecord-jdbc --no-rdoc --no-ri

  • NOTE: This is the adapter for output of your Rails application.

4. Modify config/database.yml file by using jdbc as the database adapter. E.g.

  • production:
      adapter: jdbc

      driver: com.mysql.jdbc.Driver
      url: jdbc:mysql://localhost/<your_production_database></your_production_database>
      username: <user_name></user_name>
      password:  <password></password>
      host: <hostname></hostname>

5. Modify config/environment.rb by adding

  • require 'jdbc_adapter' (NOT require 'active_record/connection_adapters/jdbc_adapter' as Rails-Integration's Wiki said!)

    • just blow line

    require File.join(File.dirname(__FILE__), 'boot')

6. Set and export $JRUBY_HOME, this will be used by GoldSpike plugin when generating WAR file.
    Actuall, you  can put all jar files used by GoldSpike under $JRUBY_HOME/lib to avoid downloading them when you generating the war file with rake, it's really annoying when you have to wait for the download complete.These jar files are (the version I use):

- activation-x.x.jar (1.1)
- bcprov-jdk14-xxx.jar (124)
- commons-pool-x.x.x.jar (1.3)
- jruby-complete-x.x.x.jar (0.9.9)
- rail-integration-x.x.x.jar (1.1.1)
- jetty-x.x.x.jar (6.1.1)

7. Put <your-db-jdbc-driver>.jar</your-db-jdbc-driver> (e.g., mysql-connector-java-5.0.5-bin.jar for MySQL) under $JRUBY_HOME/lib.

8. Generate standalone war file by executing

  • rake war:standalone:create

9. Test the war file by executing

  • rake war:standalone:run

    This use jetty. Of coure, you can deploy it to your Tomcat.

KNOWN ISSUES

  • On Tomcat, when we tried to start up the second Rails application, we got OutOfMemoryException, and we don't know whether this has something to do with the way we connect to the database.

   发表时间:2007-05-24  
beauty words
0 请登录后投票
   发表时间:2007-10-13  
Successfully
0 请登录后投票
论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics