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’
RAILS_CONNECTION_ADAPTERS = %w(jdbcmysql)
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 “Rails::Initializer.run do |config|” line. I also disable the colorized log messages to make them readable in the Eclipse console window.
config.logger = Logger.new(STDOUT)
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:
- JRuby 1.0.3: No Java-based extension library backward compatibility - by Nick Sieger



1 comment
Comments feed for this article
January 21, 2008 at 10:18 pm
pH
Hi Kiyo !!
I am struggling hardly with trying to set up Jruby on rails (sad as it may be, i does not ‘just work’ for me
)
Especially, i have problem with setting up activerecord jdbc integration.
I have been trying things for an hour now, on the JRuby wiki, on some posts by nick, installing gem with various versions, etc…
I won’t post the details here (I hope i will find some forum some day for help), but is there an authorative and comprehensive and real and working etc… place when activerecord-jdbc is explained ? With a proper environment.rb and database.rb file that just … work ?
PS : the doc here http://jruby-extras.rubyforge.org/activerecord-jdbc-adapter/ does not :P, unfortunately