Super Ray

Originally uploaded by *MSM*

I have a Rails 1.2.3 application running in JRuby 1.0.1 on Tomcat 5.5.9 at work. The application itself is not mine (actually Tim‘s), but I helped him to run it in JRuby on Tomcat so that we can utilize the existing infrastructure at work.

After I’ve got the Rails 2.0 development tools working, as recommended, I have upgraded the application to Rails 1.2.6 and successfully run it in JRuby 1.0.3 on Tomcat 6.0.10 with ActiveRecord -JDBC 0.7 and goldspike 1.4. I haven’t seen any deprecation warnings so far, which is a good sign.

Here are some short tips (and notes for myself) so far:

  • As mentioned in Nick’s post, for Rails 1.2.x to use the AR-JDBC 0.7, you need to add the followings into “config/environment.rb” in the usual spot above the “Rails::Initializer”, for example

require ‘rubygems’
gem ‘activerecord-jdbcmysql-adapter’

  • Use the absolute path with RAILS_ROOT when accessing a file directly. This is because the working directory of the webapps is different from when the rails app is running in WEBrick or mongrel.
  • Consolidate logging into one stream by configuring the both Tomcat and Rails logging to STDOUT. In “config/environment.rb” insert the followings right after the “ do |config|” line. I also disable the colorized log messages to make them readable in the Eclipse console window.

config.logger =
config.active_record.colorize_logging = false

  • I don’t use the goldspike plugin that provides tasks to package up a web archive. Instead, I use the static web.xml without “jruby.home” and “rails.env params” to make the web archive deployment environment independent. Instead I set JRUBY_HOME and RAILS_ENV.
  • In general, use Gems On Rails – “vendor everything”, which allows you to push dependent gems into your rails app thus ensuring your application will be guaranteed to work when deployed. This makes the deployment much easier even at work place. My team provides application hosting environments where only core gems are installed.

See also:

About these ads