life is a rum go guv’nor, and that’s the truth

RailsConf2007: Your First Day with JRuby on Rails

RailsConf2007. We ran in circles last night trying to find a restaurant that had been recommended to us and ended up eating at Wendy’s. Yum ;-) Apparently the double tree didn’t have our reservations. Gratefully they gave us a room anyway.

I’m here at the First Day with JRuby on Rails tutorial with Charlie Nutter and Tom Enebo. We ate lunch with them at the Oasis at the Mtn West Ruby Conference in SLC. Cool guys.

I just downloaded JRuby. This tutorial is supposed to get me started with JRuby.

To get going we include the Java library and then fire away.

First problem. This is a new laptop and while I have Eclipse loaded on it, I didn’t have a JDK installed. Ok, here goes trying to download 53 MB of JDK across the conference’s wireless. Trent predicted that the wireless would be brought down within the first 30 minutes of the conference. I guess I’m contributing to this eventuality. We will see.

Topics Charlie and Tom covered:

  • Installing JRub
  • Why JRuby?
  • Unicode support
  • Threads

I’m still back on installing Ruby thanks to no JDK installed. Even if I had that, they spent all of about 10 seconds on Installing Ruby. Hopefully they will come back to that topic later and I will have the JDK downloaded.

They are spending a lot of time talking about threads. They motivate the topic by saying “have you ever wanted to launch a long running process from ruby?” Actually yes, I have and I do. For Ozmozr and OCWFinder we run various daemons to harvest RSS and work on the database. When we first started looking at this I spent some time looking at the various open source tools available for doing RSS on Python, Ruby, and Java. I benchmarked a number of them on all three platforms. Java won hands down by about a factor of 3. I’m sure it wasn’t super scientific, but it was enough to convince me insomuch that I’ve been developing Java for about 5 years. Anyway, we wrote our daemons and harvesters in Java and it seems to be a great combination of Java and Rails (our apps are written in Rails) to solve the problems we need to.

9:02 JDK download is 23% complete

Class path. Instead of having to list full class paths you can just throw the jar files in the directory:

~/work/jruby/lib

Charlie claims that classpath is one of the most painful things about getting things up and running in Java. Funny how many times I’ve run into that. The fact that you can’t tell java to load all of the jar files in a directory is truly amusing and unexpected.

9:12 JDK download is 49% complete

Charlie mentioned that implementing migration support for JDBC was a bit challenging and required DB specific code.

Charlie points out that Java start up time is abysmal. This can be a problem if you are running lots of command line rails scripts. To solve this problem they are looking at running a Java server that you send requests to so that you don’t have to start up Java every time you want to run a script.

9:23 JDK download is 92% complete. My connection keeps flaking out. Please don’t die, please don’t die.

Set up and Deployment. Is the single aspect of Rails development right now.

9:25 Finished JDK download. Wahoo!

GoldSpike! A Rails plugin for building WAR files. A WAR file is a single file containing all of a libraries and dependencies for a web application.

They love GlassFlish (Sun’s application server). glassfish.dev.java.net. Swell. I’ll have to tell trent about this.

Mephisto is a web publishing system that contains blogging and simple CMS support. I will have to check it out.

Glitches. I had to define JRUBY_HOME to point to the root of the installed JRUBY and then add the JRUBY_HOME\bin to my path. Tom says I shouldn’t have to define JRUBY_HOME. Anyway I get all of this set up and go to my favorite rails app (OCWFinder) and try jruby script/server. Output:

Cannot find gem for Rails ~>1.2.3.0:
Install the missing gem with ‘gem install -v=1.2.3 rails’, or
change environment.rb to define RAILS_GEM_VERSION with your desired version.

Hmmm….

K, Duhh. Charlie helped me realize that I just needed to follow the slides that we blew through quickly at the beginning of the session. I needed to install rails from within JRuby:

jruby -S gem install rails

Ok, now I’m starting to see the same error messages that I’ve seen before when I didn’t have my postgres driver set up correctly. I’ll continue to follow up when I get back from lunch.

I posted my problem to #railsconf and got no help. I asked if anyone has gotten a railsapp under jruby and one person came forward but then said that it was a while ago.

I’ve seen stuff like this before, but am scratching my head on where to go right now.

NetBeans. Supposedly the best Java IDE available. Now has Ruby support.

Someone is snoring really loudly. How rude :-)

NetBeans provides for ruby: code completion, jump to declaration, and refactoring support. All things I’ve come to expect from using Eclipse. I wonder when they will be implemented there.

Someone from freenode has come onto #railsconf asking for an official contact from the conference. I guess everyone is connecting on the same IP address.

Leave a Reply