May 27, 2008

The Omen strikes again! JRuby on Rails on, yikes, Websphere.

Recently I kept my self busy, and highly frustrated trying to get a JRuby application working on WebSphere 6.1. The recipe was pretty straight forward: warble it and deploy it. Truthfully, there are a few steps that you need to be taken care of, such as configuring database.yml to point to the right place and making sure warbler.rb config file includes the proper jdbc-adapters, but that is all OK.

So, after trying the generated .war in Tomcat and confirming that it was working fine, it was time to hit WebSphere land, and guess what!, didn't work, duh!

The default web.xml configuration doesn't play well in WebSphere. The worst part is that there are no error messages, not even a trace in the logs to help.

The default web.xml spat out by warbler reads:


The filter doesn't work in WebSphere, but the servlet does the trick. So I changed the web.xml.erb within the installed gem to produce this:


Note that I've repeated the listener tag, it was intentional. WebSphere will complain if the listener declaration came after the servlet tag, it must be before, duh! again!

May 14, 2008

IBM - DB2 - Blobs - Hibernate - Truncating - Yikes!

Every project has its caveats but those that use DB2 have the omen!
Yes kids, it's rant time. Why do IBM must make developers lives through out the world so miserable? To the hell with bloated enterprise software.
After wasting time trying to figure out why Hibernate was having problems inserting blobs into DB2, our team realized the obviousness: blobs must have their size defined, no duh!

So imagine a domain object that reads:

@Entity
public class Image {
@Id @GeneratedValue(strategy = GenerationType.AUTO)
private Long id
@Lob
private byte[] image;
}

To work in IBM/DB2 land it must read:

@Entity
public class Image {
@Id @GeneratedValue(strategy = GenerationType.AUTO)
private Long id
@Lob @Column(length = 1000000)
private byte[] image;
}

And pray that your bytes don't get to big or you'll need to recompile your domain.