views:

89

answers:

1

I just recently installed JRuby and the Thrift gem after using it in MRI. I'm running into a problem where if I require 'thrift' I get the message "Unable to load thrift_native extension. Defaulting to pure Ruby libraries." If I then try and require the code thrift generated in ruby I'll get this error: "NameError: uninitialized constant Thrift::Struct_Union"

Is the thrift gem currently not working with JRuby?

Is there something I can do to use thrift with JRuby besides using the gem?

EDIT: After digging around on my mac, I found that the MRI gem and JRuby gem are different even though the gems are the same version (0.2.0.4). Now this seems like a terrible idea, but if you copy the .rb files from the MRI gem into the JRuby gem and add require 'thrift/struct_union' to thrift.rb you will no longer get any errors related to the Thrift gem except that it can't find thirft_native and will use pure Ruby libraries. This can be explained since thrift_native is made for C not Java.

+1  A: 

When you're already using JRuby, I would use a Java native thrift client. For me, thrift was the reason for moving to JRuby in the first place, since the Ruby implementation is rather slow and buggy.

Wouter de Bie
Are you saying not to use the gem and build thrift for Java? Can you still access it from within Ruby?
Aaron
It depends on where you use thrift for, but if there is a nice Java client for the application that you're connecting to, I would definitely use a Java client in favor of a Ruby one when it comes down to thrift. The beauty of JRuby is that it's so easy to use native Java code. For example, I'm using Hector for connecting to Cassandra, but call it from a Ruby application.
Wouter de Bie