Friday, September 21, 2007

Railing on JBoss

I recently successfully deployed a Ruby on Rails app running on jruby that uses ActiveRecord-JDBC adapter to talk to Oracle 10g database to run on JBoss 4.2.1. I used warbler plugin from Nick Seiger to convert the rails app to war file. I basically followed the instructions at this article about warbler (http://blog.nicksieger.com/articles/2007/09/04/warbler-a-little-birdie-to-introduce-your-rails-app-to-java) and this one on using warbler with JBoss http://www.advogato.org/person/johnnyb/. Warbler makes it very easy to convert a rails app into a war file.


There were a few quirks during this process which are listed below and hopefully these will be helpful to those trying to do the same. Theoretically this should work on any J2EE compliant app server or even Servlet containers.

  • I had to uncomment the following line in warble.rb (warbler config file)
#config.gems = ["ActiveRecord-JDBC", "jruby-openssl"]


and change it to


config.gems = ["rails", "ActiveRecord-JDBC"]


This packages rails and ActiveRecord-JDBC gems in the war file.
  • To use ActiveRecord-JDBC adapter you need to add the following code to environment.rb file

if RUBY_PLATFORM =~ /java/

require 'rubygems'

gem 'ActiveRecord-JDBC

require 'jdbc_adapter'

end

You need to be careful about where in that file you add these lines. They must be added before the line


Rails::Initializer.run do |config|

  • This one should be obvious but you need to add the jdbc driver jar to JBoss lib folder. Since I used the default configuration in Jboss I added it to C:\opt\jboss-4.2.1.GA\server\default\lib folder.

Thursday, June 21, 2007

Accessing MySql from remote machine in my network

Just got my Ubuntu box up and running with Fiesty Fawn and installed MySQL server (5.x). The default server does not allow, the MySQL server to be accessed remotely. Besides adding the user to user's table in MySQL database, I had to additionally edit my.cnf file in /etc/mysql and change the following setting:

from
bind-address = 127.0.0.1

to

bind-address = 0.0.0.0

The IP of 0.0.0.0 allows incoming connection from any host and of course you need to make sure there is not firewall in between blocking the port 3306. Since all this setup sits behind my Linux firewall it is pretty secure and allows me to develop my ROR apps from the windows box by accessing MySQL databases on another machine.

Saturday, February 10, 2007

Ruby and Rails Cheat Sheets

It is hard to remember all the useful Ruby and Rails utilities that one uses on a regular basis. But then you don't have to, there are some very commonly used Ruby and Rails related cheat sheets here and more can be easily added and shared.