Archive for the ‘JRuby’ Tag

How to run JRuby on Rails on Google’s App Engine

Are you wondering how to install your JRuby on Rails application on Google’s App Engine?

If so, go to this cookbook.

I have not tried yet, but I’ll try soon.

See you! Leo

Advertisements

Installing JRuby on Ubuntu

Today we will see how to install JRuby on Ubuntu

First of all you need to download the JRuby. Download the latest JRuby accessing the link:

http://dist.codehaus.org/jruby/

I am using the version 1.3.1 (jruby-bin-1.3.1.tar.gz)

Open a terminal and go to the directory where you have downloaded file and unpack the jruby file using the following command:

$ tar zxvf jruby-bin-1.3.1.tar.gz

We need to set some environment variables. I will add the following line at end of file .bashrc in your home directory.

export JRUBY_HOME=/home/leonardo/jruby-1.3.1
export PATH=$JRUBY_HOME/bin:$PATH

Now, Let’s check whether JRuby is installed properly, type the command:

$ jruby -v

You should see something like this:

jruby 1.3.1 (ruby 1.8.6p287) (2009-06-15 2fd6c3d) (Java HotSpot(TM) Client VM 1.6.0_13) [i386-java]

Alright! If you are able to see the JRuby version, your system is configured properly.

Now you can start installing some gems:

$ jruby -S gem install jruby-openssl

jruby-openssl is necessary due JRuby doesn’t support the default Ruby’s openssl.

The parameter -S tells JRuby to use the scripts which are in JRuby’s bin directory, then in a second case to use the which ones in the system PATH.

If you want to install Rails:

$ jruby -S gem install rails

That’s all about!

Warbler 0.9.9 default servlet filter config doesn’t work with Websphere 6.1

Many people have been facing some issue when trying to deploy a JRuby on Rails package using Warbler on WebSphere AS 6.1.

One workaround is to copy the file JRUBY_HOME/lib/ruby/gems/1.8/gems/warbler-0.9.9/web.xml.erb to your app/config diretory and change it to use a Servlet instead of a Filter as below:

<!DOCTYPE web-app PUBLIC

“-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN”

  "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
  <% webxml.context_params.each do |k,v| %>
  <context-param>
      <param-name><%= k %></param-name>
      <param-value><%= v %></param-value>
  </context-param>
  <% end %>

  <listener>
      <listener-class><%= webxml.servlet_context_listener %></listener-class>
  </listener>

  <servlet>
      <servlet-name>Rails</servlet-name>
      <servlet-class>org.jruby.rack.RackServlet</servlet-class>
  </servlet>

  <servlet-mapping>
      <servlet-name>Rails</servlet-name>
      <url-pattern>/*</url-pattern>
  </servlet-mapping>

  <% if webxml.jndi then webxml.jndi.each do |jndi| %>
  <resource-ref>
      <res-ref-name><%= jndi %></res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
  </resource-ref>
  <% end; end %>
</web-app>

Also instead of changing the web.xml.erb file to use Servlet you can configure your WebSphere AS to work with Rack Filter. To do that you have to:

1. Start the Websphere server and open the Administration Console
2. Set a Websphere web container custom property com.ibm.ws.webcontainer.invokefilterscompatibility = true.

If you have some difficult to find where to set this configuration tell me and I will give you the step-by-step.

I hope this tip be useful for everyone that is getting to work with JRuby On Rails on WebSphere.

All the best,

Leo