↓ Archives ↓

Posts Tagged → jruby

RailsInstaller (and obligatory RailsFTW comparison)

The true successor to InstantRails is out: Wayne Sequin of RVM fame, with the help of Dr. Nic Williams and RubyInstaller‘s Luis Lavena, has just released the first version of RailsInstaller.

RailsInstaller

Now I can finally stop worrying about how to find time to maintain RailsFTW. :D

Just like with JRuby 1.6.0RC1, I’ve taken time to try out RailsInstaller on my machine. Here are some quick thoughts about it:

RailsInstaller is HUEG

RailsInstaller is HUGE. The installer is already quite large at 42MB, and as you can see from the screenshot above, the whole installation takes up a third of a gig of your hard drive. Bundling DevKit (basically MinGW for gem compilation) and Git really increased the size of the package.

In comparison, RubyInstaller’s 1.8.7 and 1.9.2 installers are only 10MB and 12MB, respectively. RailsFTW v0.4 is also pretty small at 13MB packaged, 46MB installed. I’d suggest they do the same as what I did with RailsFTW and remove the cached gems to lower the package size by an MB or two.

Another difference with RailsFTW is the Ruby version used. To provide maximum compatibility, RailsInstaller uses Ruby 1.8.7 instead of RailsFTW’s 1.9.2.

My initial reaction to this was “Wouldn’t 1.8.7 be slower than 1.9.2 because of the latter’s YARV?” Based on testing, however, 1.8.7 is consistently faster than 1.9.2 in both generator scripts (rails new, rails g scaffold) as well as serving a site via WEBrick.

The results are weird, but I guess we could blame that on caching and Windows IO and how they screw up how YARV works.

When compared to JRuby 1.6.0RC1, 1.8.7 is (as expected) much faster in the generator scripts, but also much slower (again as expected) in the WEBrick test. Nothing surprising here.

MariaDB

The last obvious difference between RailsInstaller and RailsFTW is MySQL support. RailsFTW comes with a mysql2 gem installed using MariaDB 5.2.4. It also comes with the libmysql.dll from the same package. Having both in RailsFTW allows users to use Rails with MySQL (say, via XAMPP) out of the box without me having to worry about Oracle’s lawyers.

The only catch here is that a fix is required to enable MariaDB-based installation meaning that the gem I used isn’t exactly the same gem that you download from RubyGems.

In closing, while I’m glad that there’s finally a professional alternative to my hacked-together Rails Windows installer, I don’t think RailsFTW has been totally superceded by RailsInstaller. At this point, it’s a matter of choosing between the RailsFTW minimalism and MySQL support vs RailsInstaller’s bundled Git and compatibility support via 1.8.7 + DevKit.

In the next RailsJam-type event, I’d probably leave the choice to the attendees. Some might favor a lower hard drive footprint and instant MySQL support, while others might favor having a bundled Git and DevKit to prepare themselves for more advanced Rails projects.

This post by Bryan Bibat is from existence, refactored.

Redmine on Jruby

To be able to take advantage of jruby, you need to add config.threadsafe! on your rails app. I tried doing this on redmine 1.0.2 but some pages were not working. Some of the errors were

uninitialized constant Redmine::Views::OtherFormatsBuilder
uninitialized constant Redmine::DefaultData
uninitialized constant Redmine::Activity::Fetcher
uninitialized constant ActionView::Base::CompiledTemplates::TabularFormBuilder

I got it to work by changing config/initializers/30-redmine.rb to

I18n.default_locale = 'en'
dirs = ["SVG", "redmine"]
files = []
lib_path = "#{RAILS_ROOT}/lib"
matcher = /\A#{Regexp.escape(lib_path)}\/(.*)\.rb\Z/
dirs.each do |dir|
  files += Dir.glob("#{lib_path}/#{dir}/**/*.rb")
end
files += Dir.glob("#{lib_path}/*.rb")
files.each do |file|
  require file.sub(matcher, '\1')
end

Adding RAILS_ROOT/lib to config.eager_load_paths doesn’t work. If there is a better way, let me know in the comments.

This post by Christopher Rigor is from crigor.com.

Ruby on Windows

Some posts just write themselves. Today’s post comes from my reply to a guy in PhRUG who still thinks you need a Mac before you can develop Rails applications.

windows and ruby

The biggest problem the Ruby/Rails community has when trying to spread the word in this country: the lack of interest in supporting Windows.

I mean, a typical response to the legitimate question “I’m using Windows, how to I practice RoR?” is the fanboy answer: “Get a Mac!”

And that, my dear readers, is a dick move. If I was an average college student and you told me that, I’ll immediately think “WTF?!? I just want to try out this open-source language and web framework and I need to shell out a couple of years worth of tuition?!?

Answering “Format your hard drive and install Linux” is less of a dick move, but a dick move nonetheless.

Thus, if we rubyists want to spread the word about Ruby, we’ll have to make Windows a viable OS for Ruby development. Here are a few options available to us:


Use Ruby 1.9.2

Startup speed is probably the main problem with developing Rails in Windows. Fortunately, Ruby 1.9 is a heck of a lot faster than 1.8 thanks to the new interpreter.

I tried to install Rails 3 on my gaming rig just now to see the difference.

  • Downloaded and installed the 1.9.2 installer from the official ruby site. Note that you must tick the Add Ruby executables to your path to remove the need for doing that later.

ruby installer

  • Went to the command prompt (I used PowerShell because it’s just better) and installed Rails 3 using the same command for installing it in Linux or OS X: gem install rails --no-ri --no-rdoc

installing rails

  • Downloaded SQLite3 Windows DLL from the official download page and extracted it to the Ruby bin directory (use gem env to determine the path)

gem env

  • Created the 6-command blog program. (cd blog not included in pics)

rails new blog

bundle install

rails generate scaffold

rake db:migrate

rails server

  • Opened http://localhost:3000/entries in a browser. Works as expected.

open browser

Conclusion: Ruby 1.9 on Windows is pretty fast. Have the newbie install this along with NetBeans or RadRails and he should be diving into Rails in no time.

Virtualization (my personal choice)

virtual machine

The problem with Windows is that some important gems (rvm, unicorn, and passenger) are not supported by the OS. Fortunately, with a decent computer, you can run Linux inside of Windows without having to dual boot. VirtualBox or VMWare Player are both free virtualization options available on Windows.

For a gaming level rig (~4 GB RAM, RAM is pretty cheap nowadays), installing Ubuntu Desktop 10.4 (Lucid Lynx) on a VM with 10GB of space and 1GB of RAM should be more than enough for development needs. If you want to use a Windows editor/IDE to edit your files, you can setup shared folders to gain access to the files from the host PC.

For a slightly weaker machine, you could install Ubuntu Server on a VM with 10GB of space and 512MB of RAM, and voila! instant VPS on your PC. You can even use openssh-sever + PuTTY to emulate having multiple terminal windows.

JRuby

Pretty much the same as MRI Ruby with some minor differences. We don’t have rvm on Windows so you’ll have to change all of your “ruby” commands with “jruby” and prefix your ruby system commands with “jruby -S” e.g. “jruby -S gem ...“.

Downside is that it has the slow startup speed of 1.8 (they say you could tweak it to preload the libraries faster, but I haven’t tried it myself) and the native extension problems of having a different environment.

On the plus side, it’s on the JVM: just package your project into a WAR file with Warbler and it should be deployable on any J2EE application server. Great for convincing J2EE software houses to try out Rails.

In closing, if you’ve got a MacBook Pro and someone asks you about developing Rails on a PC, don’t be a dick and tell them “Get a Mac!”. Ruby is just fine regardless of whether you’re using Windows, Linux, or OS X.

This post by Bryan Bibat is from existence, refactored.

Deploy a Rails 3, Sqlite3 application in Tomcat using JRuby

and have a Ruby version running side-by-side.

A few months ago I got interested in JRuby while researching for text mining algorithms. I found some gems but they are either unmaintained or inadequate while the mature libraries I found were written in Java. No problem! JRuby to the rescue. Thank God.

Next stop, I decided to take Rails 3 and JRuby for a spin. Incidentally, I will be on a 3-city Rails tour in the Philippines this September and since there are many Filipino Java developers, they might find it interesting to see their favorite Java platform works nicely with Ruby on Rails.

Setup

I will be using the following for this tutorial:

java 1.6 + JDK
tomcat 7.0.2
rvm 1.0.1
jruby 1.5.0
ruby 1.9.2p0

Further below, I outline how to install these software. First, let’s see my current environment.

$ more /etc/issue
Ubuntu 9.10 \n \l

$ java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Server VM (build 16.3-b01, mixed mode)

$ rvm -v
rvm 1.0.1 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]

$ jruby -v
jruby 1.5.0 (ruby 1.8.7 patchlevel 249) (2010-05-12 6769999) (Java HotSpot(TM) Client VM 1.6.0_20) [i386-java]

$ TOMCAT/bin/version.sh
Using CATALINA_BASE:   /usr/local/apache-tomcat-7.0.2
Using CATALINA_HOME:   /usr/local/apache-tomcat-7.0.2
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-7.0.2/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/apache-tomcat-7.0.2/bin/bootstrap.jar:/usr/local/apache-tomcat-7.0.2/bin/tomcat-juli.jar
Server version: Apache Tomcat/7.0.2
Server built:   Aug 4 2010 12:23:47
Server number:  7.0.2.0
OS Name:        Linux
OS Version:     2.6.31-22-generic
Architecture:   i386
JVM Version:    1.6.0_20-b02
JVM Vendor:     Sun Microsystems Inc.

$ ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]

Install JDK and Tomcat

$ aptitude install curl sun-java6-bin sun-java6-jre sun-java6-jdk
$ wget  http://apache.mobiles5.com/tomcat/tomcat-7/v7.0.2-beta/bin/apache-tomcat-7.0.2.tar.gz
$> tar zxvf apache-tomcat-7.0.2.tar.gz
$> mv apache-tomcat-7.0.2 /usr/local

Of course, these assume you want to use 7.0.2 and you want it installed at your /usr/local.

Install JRuby, Rails 3

I assume you already have rvm installed. If not, I highly recommend that you do. I can’t imagine a Ruby developer not using rvm :)

$ rvm install jruby
$ rvm jruby
$ rvm gemset create railsjam
$ rvm jruby@railsjam
$ gem install rails

Try a sample app

I’ve created sample app for the RailsJam tour. This have several functionalities already and better than creating a Rails app from scratch.

$ git clone git://github.com/gregmoreno/railsjam.git

Update the Gemfile

You need a separate set of gems to make your Rails 3 application work with JRuby. For learning purposes, I want my Rails 3 application to work other than JRuby. To accomplish that, we need to specify what gems are needed solely by JRuby.

source 'http://rubygems.org'

gem 'rails', '3.0.0'

if defined?(JRUBY_VERSION)
  gem 'jdbc-sqlite3'
  gem 'activerecord-jdbc-adapter'
  gem 'activerecord-jdbcsqlite3-adapter'
  gem 'jruby-openssl'
  gem 'jruby-rack'
  gem 'warbler'
else
  gem 'sqlite3-ruby', :require => 'sqlite3'
end

(A copy of this Gemfile is available at the ‘jruby’ folder of the railsjam application.)

Now, it’s time to intall the gems.

# Must do this. Otherwise,  bundle picks up wrong version of jdbc
$ rm Gemfile.lock
$ jruby -S bundle install

Prepare the database.

The first time I worked on this tutorial, I needed to specify the jdbcsqlite3 as the database adapter. However, when I tried the tutorial on the same machine with a fresh gemset, it worked pretty well with just ‘sqlite3’. Just to be sure, I modified ‘database.yml’ to check for JRuby.

development:
  adapter: <%= defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3' %>
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: <%= defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3' %>
  database: /home/greg/dev/railsjam/db/development.sqlite3
  pool: 5
  timeout: 5000

When you deploy to Tomcat, it will be on ‘production’ mode by default. Since sqlite3 is file based and for simplicity, I used the same development database.

Now, do the migration.

$ jruby -S rake db:migrate

Deploy to Tomcat

We use ‘warble’ which is an excellent tool for packaging your Rails application. It packages everything you need to run your Rails application inside a Java container.

$ warble
$ cp railsjam.war  $TOMCAT/webapps

# start Tomcat
# assuming you arein $TOMCAT dir
$ sudo ./startup.sh

Check your Rails 3 application

# You should see the famous Rails welcome
localhost:3000/railsjam

# Play around with your application
localhost:3000/railsjam/users

Deploy Rails 3 using Ruby 1.9.2

Without shutting down your JRuby and Tomcat version, let’s try to run our app using Ruby 1.9.2

# In a new console
$ rvm 1.9.2
$ rvm gemset create railsjam
$ rvm 1.9.2@railsjam
$ gem install rails

# Assuming you are in the ‘railsjam’ folder
# This will install sqlite3-ruby gem
$ bundle install

$ rails server

Now, go play with your Rails 3 applications

# jruby + tomcat

http://localhost:8080/railsjam/users

# ruby 1.9.2

http://localhost:3000/users

In case you encountered some problems, here are some ways to solve them. If your problem is not listed here, you can email me. I only accept Paypal :)

JRuby does not support native extensions

You did not update the Gemfile to use the jdbc version of sqlite3. You will encounter this error when you install the gems.

$ bundle install
....
Installing sqlite3-ruby (1.3.1) with native extensions /home/greg/.rvm/rubies/jruby-1.5.2/lib/ruby/site_ruby/1.8/rubygems/installer.rb:482:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/home/greg/.rvm/rubies/jruby-1.5.2/bin/jruby extconf.rb
WARNING: JRuby does not support native extensions or the `mkmf' library.
         Check http://kenai.com/projects/jruby/pages/Home for alternatives.
extconf.rb:9: undefined method `dir_config' for main:Object (NoMethodError)

undefined method `attributes_with_quotes’ for class `ActiveRecord::Base’

I first encountered this problem when doing migration.

$ rake db:migrate
rake aborted!
undefined method `attributes_with_quotes' for class `ActiveRecord::Base'

This is caused by an old version of your jdbc gems. In my case, sometimes bundler installs the old versions:

Installing activerecord-jdbc-adapter (0.9.2)
Installing activerecord-jdbcsqlite3-adapter (0.9.2)

As of this writing, the latest version is 0.9.7

Installing activerecord-jdbc-adapter-0.9.7-java
Installing activerecord-jdbcsqlite3-adapter-0.9.7-java

Bundler keeps installing 0.9.2

$ rm Gemfile.lock
$ jruby -S bundle install

no such file to load — sqlite3

$ rake db:migrate
(in /home/greg/dev/projects/jruby/railsjam)
rake aborted!
no such file to load -- sqlite3

‘sqlite3’ is the default name of the database adapter but with jruby, it should be ‘jdbcsqlite3’. (another) But, when I tried ‘sqlite3’ with a fresh gemset and a new machine, it went well. Anyway, just in case you run into the same problem in the future, add a condition in your database.yml

development:
  adapter: <%= defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3' %>
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

We’re sorry, but something went wrong.

If you see the famous Rails error message, you need to dig in Tomcat’s log files.

$ cd /usr/local/apache-tomcat-7.0.2/logs
$ ls -al localhost*

-rw-r--r-- 1 root root 1181 2010-09-01 00:17 localhost.2010-09-01.log
-rw-r--r-- 1 root root 1062 2010-09-01 00:18 localhost_access_log.2010-09-01.txt

$ tail -f localhost.2010-09-01.log

In the log file, you will see the errors like missing database.

org.jruby.rack.RackInitializationException: The driver encountered an error: java.sql.SQLException: path to ‘/home/greg/dev/tmp/apache-tomcat-7.0.2/webapps/railsjam/WEB-INF/db/production.sqlite3′: ‘/home/greg/dev/tmp/apache-tomcat-7.0.2/webapps/railsjam/WEB-INF/db’ does not exist

Related posts:

  1. Rails 3 upgrade part 1: Booting the application It’s time for another Rails upgrade! We all have our share of bad experiences and frustrations every time we upgrade a piece of software. Even for technical people who live...
  2. How to setup a Rails 3 app I finally decided to give Rails 3 a spin after beta was released 20 days ago. In geek time, that’s being a late adopter. But first, a warning. I’ve read...
  3. Rails 3 upgrade part 4: Prototype helpers and Javascript Rails 3 is embracing the unobtrusive Javascript (or UJS) mantra which is good because it is the right way; at the same time, it is bad because many applications will...


This post by Greg Moreno is from MetaGreg.

Deploy a Rails 3, Sqlite3 application in Tomcat using JRuby

and have a Ruby version running side-by-side.

A few months ago I got interested in JRuby while researching for text mining algorithms. I found some gems but they are either unmaintained or inadequate while the mature libraries I found were written in Java. No problem! JRuby to the rescue. Thank God.

Next stop, I decided to take Rails 3 and JRuby for a spin. Incidentally, I will be on a 3-city Rails tour in the Philippines this September and since there are many Filipino Java developers, they might find it interesting to see their favorite Java platform works nicely with Ruby on Rails.

Setup

I will be using the following for this tutorial:

java 1.6 + JDK
tomcat 7.0.2
rvm 1.0.1
jruby 1.5.0
ruby 1.9.2p0

Further below, I outline how to install these software. First, let’s see my current environment.

  $ more /etc/issue
  Ubuntu 9.10 \n \l
  
  $ java -version
  java version &quot;1.6.0_20&quot;
  Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
  Java HotSpot(TM) Server VM (build 16.3-b01, mixed mode)
  
  $ rvm -v
  rvm 1.0.1 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]
  
  $ jruby -v
  jruby 1.5.0 (ruby 1.8.7 patchlevel 249) (2010-05-12 6769999) (Java HotSpot(TM) Client VM 1.6.0_20) [i386-java]
  
  $ TOMCAT/bin/version.sh 
  Using CATALINA_BASE:   /usr/local/apache-tomcat-7.0.2
  Using CATALINA_HOME:   /usr/local/apache-tomcat-7.0.2
  Using CATALINA_TMPDIR: /usr/local/apache-tomcat-7.0.2/temp
  Using JRE_HOME:        /usr
  Using CLASSPATH:       /usr/local/apache-tomcat-7.0.2/bin/bootstrap.jar:/usr/local/apache-tomcat-7.0.2/bin/tomcat-juli.jar
  Server version: Apache Tomcat/7.0.2
  Server built:   Aug 4 2010 12:23:47
  Server number:  7.0.2.0
  OS Name:        Linux
  OS Version:     2.6.31-22-generic
  Architecture:   i386
  JVM Version:    1.6.0_20-b02
  JVM Vendor:     Sun Microsystems Inc.
  
  $ ruby -v
  ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]
  
  # install jdk and tomcat
  
  $ aptitude install curl sun-java6-bin sun-java6-jre sun-java6-jdk
  $ wget  http://apache.mobiles5.com/tomcat/tomcat-7/v7.0.2-beta/bin/apache-tomcat-7.0.2.tar.gz
  $ tar zxvf apache-tomcat-7.0.2.tar.gz
  $ mv apache-tomcat-7.0.2 /usr/local
  

Of course, these assume you want to use 7.0.2 and you want it installed at your /usr/local.

Install JRuby, Rails 3

I assume you already have rvm installed. If not, I highly recommend that you do. I can’t imagine a Ruby developer not using rvm :)

  $ rvm install jruby
  $ rvm jruby
  $ rvm gemset create railsjam
  $ rvm jruby@railsjam
  $ gem install rails

Try a sample app

I’ve created sample app for the RailsJam tour. This have several functionalities already and better than creating a Rails app from scratch.

$ git clone git://github.com/gregmoreno/railsjam.git

Update the Gemfile

You need a separate set of gems to make your Rails 3 application work with JRuby. For learning purposes, I want my Rails 3 application to work other than JRuby. To accomplish that, we need to specify what gems are needed solely by JRuby.

  source 'http://rubygems.org'
  
  gem 'rails', '3.0.0'
  
  if defined?(JRUBY_VERSION)
    gem 'jdbc-sqlite3'
    gem 'activerecord-jdbc-adapter'
    gem 'activerecord-jdbcsqlite3-adapter'
    gem 'jruby-openssl'
    gem 'jruby-rack'
    gem 'warbler'
  else
    gem 'sqlite3-ruby', :require => 'sqlite3'
  end

(A copy of this Gemfile is available at the ‘jruby’ folder of the railsjam application.)

Now, it’s time to intall the gems. You must delete ‘Gemfile.lock’. Otherwise, bundle picks up wrong version of jdbc

  $ rm Gemfile.lock  
  $ jruby -S bundle install

Prepare the database.

The first time I worked on this tutorial, I needed to specify the jdbcsqlite3 as the database adapter. However, when I tried the tutorial on the same machine with a fresh gemset, it worked pretty well with just ‘sqlite3’. Just to be sure, I modified ‘database.yml’ to check for JRuby.

  development:
    adapter: <%= defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3' %>
    database: db/development.sqlite3
    pool: 5
    timeout: 5000
  
  production:
    adapter: <%= defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3' %>
    database: /home/greg/dev/railsjam/db/development.sqlite3 
    pool: 5
    timeout: 5000

When you deploy to Tomcat, it will be on ‘production’ mode by default. Since sqlite3 is file based and for simplicity, I used the same development database.

Now, do the migration.

  $ jruby -S rake db:migrate

Deploy to Tomcat

We use ‘warble’ which is an excellent tool for packaging your Rails application. It packages everything you need to run your Rails application inside a Java container.

  $ warble
  $ cp railsjam.war  $TOMCAT/webapps
  
  # start Tomcat
  # assuming you arein $TOMCAT dir
  $ sudo ./startup.sh

Check your Rails 3 application

  # You should see the famous Rails welcome
  localhost:3000/railsjam
  
  # Play around with your application
  localhost:3000/railsjam/users

Deploy Rails 3 using Ruby 1.9.2

Without shutting down your JRuby and Tomcat version, let’s try to run our app using Ruby 1.9.2

  # In a new console
  $ rvm 1.9.2
  $ rvm gemset create railsjam
  $ rvm 1.9.2@railsjam
  $ gem install rails
  
  # Assuming you are in the ‘railsjam’ folder
  # This will install sqlite3-ruby gem
  $ bundle install
  
  $ rails server
  
  Now, go play with your Rails 3 applications
  
  # jruby + tomcat
  http://localhost:8080/railsjam/users
  
  # ruby 1.9.2
  http://localhost:3000/users

In case you encountered some problems, here are some ways to solve them. If your problem is not listed here, you can email me. I only accept Paypal :)

JRuby does not support native extensions

You did not update the Gemfile to use the jdbc version of sqlite3. You will encounter this error when you install the gems.

   
  $ bundle install
  ....
  Installing sqlite3-ruby (1.3.1) with native extensions /home/greg/.rvm/rubies/jruby-1.5.2/lib/ruby/site_ruby/1.8/rubygems/installer.rb:482:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
  
  /home/greg/.rvm/rubies/jruby-1.5.2/bin/jruby extconf.rb 
  WARNING: JRuby does not support native extensions or the `mkmf' library.
           Check http://kenai.com/projects/jruby/pages/Home for alternatives.
  extconf.rb:9: undefined method `dir_config' for main:Object (NoMethodError)

undefined method `attributes_with_quotes’ for class `ActiveRecord::Base’

I first encountered this problem when doing migration.

 
  $ rake db:migrate
  rake aborted!
  undefined method 'attributes_with_quotes' for class 'ActiveRecord::Base'

This is caused by an old version of your jdbc gems. In my case, sometimes bundler installs the old versions:

  Installing activerecord-jdbc-adapter (0.9.2) 
  Installing activerecord-jdbcsqlite3-adapter (0.9.2)

As of this writing, the latest version is 0.9.7

  Installing activerecord-jdbc-adapter-0.9.7-java
  Installing activerecord-jdbcsqlite3-adapter-0.9.7-java

Bundler keeps installing 0.9.2

  
  $ rm Gemfile.lock
  $ jruby -S bundle install

no such file to load — sqlite3

  $ rake db:migrate
  (in /home/greg/dev/projects/jruby/railsjam)
  rake aborted!
  no such file to load -- sqlite3

‘sqlite3′ is the default name of the database adapter but with jruby, it should be ‘jdbcsqlite3′.
But, when I tried ‘sqlite3′ with a fresh gemset and a new machine, it went well.
Anyway, just in case you run into the same problem in the future, add a condition
in your database.yml

  development:
    adapter: <%= defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3' %>
    database: db/development.sqlite3
    pool: 5
    timeout: 5000
  
  production:
    adapter: <%= defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3' %>
    database: /home/greg/dev/railsjam/db/development.sqlite3 
    pool: 5
    timeout: 5000

We’re sorry, but something went wrong.

If you see the famous Rails error message, you need to dig in Tomcat’s log files.

  $ cd /usr/local/apache-tomcat-7.0.2/logs
  $ ls -al localhost*
  
  -rw-r--r-- 1 root root 1181 2010-09-01 00:17 localhost.2010-09-01.log
  -rw-r--r-- 1 root root 1062 2010-09-01 00:18 localhost_access_log.2010-09-01.txt
  
  $ tail -f localhost.2010-09-01.log 

In the log file, you will see the errors like missing database.

  org.jruby.rack.RackInitializationException: The driver encountered an error: java.sql.SQLException: path to '/home/greg/dev/tmp/apache-tomcat-7.0.2/webapps/railsjam/WEB-INF/db/production.sqlite3': '/home/greg/dev/tmp/apache-tomcat-7.0.2/webapps/railsjam/WEB-INF/db' does not exist


This post by Greg Moreno is from Greg Moreno.