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

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: