You are currently browsing the tag archive for the ‘jruby’ tag.

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:


JRuby on Rails in Tomcat inside Eclipse (Part 2)
Originally uploaded by Lilly

It was only a few weeks ago when JRuby 1.0.2 did not work well with Rails 2.0.1. Now JRuby 1.0.3 is out and Rails 2.0.2 is out, too.

So I have tried this again – JRuby on Rails in Eclipse IDE with WebTools Platform and RadRails.

Since RadRails 0.9.1 which has fixed compatibility issues with Eclipse 3.3 was out in November, I have upgraded Eclipse to 3.3.1 with WebTools Platform 2.0.1. I have also upgraded Tomcat to 6.0 as WTP 2.0 supports it.

ActiveRecord-JDBC 0.7 and GoldSpike 1.4 are just out, too. Basically I have upgraded everything and they have worked well together. I am going to upgrade or maybe re-write a few of my old rails apps in this development environment. How exciting!

See also:

The avenue in mist and sun

Originally uploaded by algo

Spring JMS has made JMS easy. JRuby makes it even easier.

I have used the OpenAdaptor as JMS clients for benchmarking and supporting tasks. With many ready-built components I can do most of things I need to do, but sometimes I can’t do simple things like sending a sample message in a file repeatedly for benchmarking unless I do a bit of java programming to extend the existing components.

The Spring’s SimpleMessageContrainer works well as a simple subscriber like for benchmarking or draining messages. I just needed to set the AutoStartup to false and set a JRuby implementation of the MessageListener to the SimpleMessageContainer bean programmatically before starting it up.

However, the JmsTemplate falls short on the publishing side, i.e. it opens and closes a session every time it sends a message. James Strachan has more on that. So I needed to create a session and a publisher in JRuby. Even so, it’s still easy as the Spring does the rest.

OpenAdaptor’s JMS Peek utility is useful as a diagnostic aid especially for Topic as it does not have a browsing interface like QueueBrowser. There were a few support cases in the past where users wanted to peek more than one messages. Not surprisingly, it was easily done in JRuby with Spring JMS. Fisrt, I tried to set the SessionAcknowledgeMode of SimpleMessageContainer to CLIENT_ACKNOWLEDGE, but it turned out that the SimpleMessageContainer called acknowledge() on Message. So, like the JRuby publisher, I have created a durable subscriber to receive a number of messages without acknowledging them.

Here are source codes of the above JRuby scripts. They are good enough to get simple things done quickly and simply. That’s why I love JRuby.

Related Posts:

Time to Mingle…
Originally uploaded by l. argos

I installed ThoughtWorks Studios’ Mingle (Early Access Windows Version) a few weeks ago. I was interested in Mingle only because it runs on JRuby.

The installation was straightaway. It just worked. It runs a small executable called MingleServer.exe in which something are hidden. Hmm. Most of the ruby codes are obfuscated to protect IP. Fair enough. But, still it is interesting to see how it is deployed.

Mingle freezes not only rails but also all required gems.Everything even JRE is in one package to guarantee it will work when deployed. I have used Gems On Rails (aka vendor everything) to freeze some gems, but I could not get freezed ActiveRecord-JDBC working when I tried to run JRuby on Rails in Tomcat. Fortunately config files are not obfuscated. The environment.rb includes similar codes to Gems On Rails, which might be a trick to get all working.

Mingle has a retty plugin installed. Retty is a Ruby on Rails plugin that lets Jetty run as a server using JRuby. Even though it’s specific to Rails, it’s very interesting to read the server code since I tried the Jetty in JRuby, too.

Now 1.0 general release is available with an interesting pricing. I might try UNIX version to see if anything changed or wait for 1.1 release which will be delivered as a .war file that can be deployed on any of the popular Java EE application servers.

P.S. I’ve just realized that the public search on does not search comments. Why? Google crawl the comment feed of each post.

Related Posts:

and i’ve been workin’ like a dog
Originally uploaded by manyfires

JRuby has proved (to me at least) to be really powerful in prototyping and learning Java APIs. A few weeks ago I started thinking to rewrite one of my old Java programs in JRuby. I wrote that Java program as part of learning Java programming (so it’s not as good as I hoped) and I am no longer interested in maintaining it in Java since I’ve learned JRuby. I also thought that I made it a bit complicated to maintain. So I am hoping to simplify it by rewriting in JRuby and Ruby. It will be a challenge for me since I am still learning Ruby, but I hope I enjoy it.

The program calls various JMX APIs on a JMS server periodically and publishes outputs in XML onto JMS. The JMS server has a JMX Console, but I needed a web application for a consolidated view to monitor a number of JMS servers and clients on them.

It was not difficult at all to rewrite one part of the program, calling JMX APIs in JRuby. However, I thought twice about the data transport. Although it’s possible to use JMS in JRuby, inspired by Joe Gregorio’s RESTful JSON, I have decided to use JSON as data transport format this time. Bearing in mind the further integration with the current infrastructure at work, I have also chosen Jetty as HTTP server. Thanks to Keith who has shared his experience in running Jetty in JRuby. Jetty has JSON libraries built in, which is a bonus.

During the development, I’ve found Eyal’s JSON Viewer handy (even I have to cut & paste JSON data from cURL output) since browsers do not render response which content type is “application./json”, while you can view unformatted JSON with Firebug’s network monitoring. Does anyone know anything like Michael Bolin‘s JSON Inspector?

So far I’ve got the RESTful JSON webservice working for some GET requests. Now I need to think about URIs mapping and implementation of other JMX functions I use. I will post follow-up if I find something worthy to post.

P.S. The photo is nothing to do with this post, but as always I love to attach a wonderful photo (and story, too) I’ve found in Flickr.

Related Posts:

All Your Famous Friends
Originally uploaded by Thomas Hawk

I have waited for this news, JRuby 1.0.0RC3 Released – And This Is It!

I have already managed to run an example of JRuby on Rails in Tomcat with PKI at work. So what I need next was an application development environment and I’ve got JRuby on Rails running on Tomcat inside Eclipse IDE with Eclipse WebTools Platform and Aptana’s RadRails plugin.

I already have a Tomcat package coupled with JASS (Java Authentication and Authorisation Service) framework at work, which works nicely within Eclipse IDE with WTP. So, I just needed to install RadRails as a plugin to that. I can only use RadRails to develop a Rails app, but can’t run it in WEBrick because it calls Java JASS API functions to get out other information about the user. However, you can add it to a Tomcat server as an external web module (you can’t add this as a web module because it’s not a web project, but a rails project) so that you can run the Rails app with JRuby in Tomcat within Eclipse! Here is a short instruction.

  1. Download the Eclipse + WTP all-in-one package
  2. Install RadRails and configure it
  3. Create a new Rails project
  4. Create a WEB-INF folder with necessary files in the root of the project
  5. Create a new server (e.g. Tomcat)
  6. Add the Rails project as an external web module to the server. You just point the directory where the Rails project resides in and give a path like /projectname.
  7. Start the server
  8. Open a browser in Eclipse and access the webapp (screenshot)

Related Posts:

Ruby on Rails
Originally uploaded by photosuze.

I have been checking the progress of JRuby since RailsConf Europe 2006. The time has come to try this out.

“Drop Rails into TomCat and it just works” – Ola Bini

“JRuby is ready for prime time. Application developers should try their applications on JRuby NOW” – Ola Bini

I had a minor problem with its installation, but I’m impressed very much when I’ve got JRuby-0.9.9, Rails-1.2.3, Tomcat-5.5.9 and PKI framework at work working together nicely. A big thank you to the JRuby team.

The problem I had was nothing to do with JRuby, but Subversion. I could not checkout the rails-integration at work since the svn protocol was blocked (“Unknown hostname ‘'” error) and RubyForge did not allow the checkout over http (405 Method Not Allowed error). When I tried it on a work laptop at home, it still did not work ( Can’t connect to hose ‘’: A connection attempt failed because the connected party did not properly respond after a period of time, or …). In the end I had to disable a firewall software. Hope this saves someone else’s time.

I am really looking forward to JRuby 1.0. It’s a very exciting time.

I can’t go RailsConf 2007, but I want a JRuby T-Shirt!

Related Posts:


Blog Stats

  • 87,765 hits