Archive for the ‘Ruby/JRuby’ Category

Random Java Stuff

Thursday, June 28th, 2007

Java Genetic Algorithms Package (JGAP) is (surprise) a genetic algorithm package for Java. JGAP 3.2 was recently released. Coolest feature: you can use JGAP to evolve a Robocode robot (more about Robocode).

After reading this post by Bill Pugh to OpenJDK’s quality-discuss mailing list, I immediately gave FindBugs a try. The Eclipse plugin for FindBugs is highly recommended. Getting FindBugs going is Maven is a bit more… interesting. I think you want the findbugs-maven-plugin, although there’s also a maven-findbugs-plugin. It seems findbugs-maven-plugin includes support for FindBugs 1.2.0, but I wasn’t able to consistently convince it to use that instead of 1.0.0. Good luck.

I promptly unleashed FindBugs on Apache ActiveMQ and found some minor issues and some more serious issues. Maximum respect to Rob Davies for fixing the latter collection.

Update: I unleashed FindBugs on JRuby. See JRUBY-1173.

pyactivemq does threads

Friday, June 1st, 2007

After employing various debugging techniques (mostly some RTFM and printf debugging), I was able to get C++ threads to call back into Python code successfully. In pyactivemq, this allows you to register a MessageListener on a Session and have the thread associated with the Session call into Python whenever a message arrives.

All the info I needed to solve the problem was contained in PEP 311: Simplified Global Interpreter Lock Acquisition for Extensions and Thread State and the Global Interpreter Lock. My main mistake was that I didn’t call PyEval_InitThreads() in my module’s initialization code, which seems to turn attempts to acquire the GIL into a no-op, which meant that I had multiple threads calling into the interpreter at the same time, with the associated “interesting” results.

My weekend on JRuby on Rails

Sunday, May 20th, 2007

I played with JRuby and Rails this weekend.

I’m trying to create a standalone JAR that contains Jetty and a Rails application so that you can fire up a server using java -jar railsapp.jar, like you can do with Hudson. This involves taking the existing work that allows you to bundle your Rails application into a WAR (which can be deployed to a server) a bit further. I haven’t quite figured out how to configure Jetty to do this yet. It seems Jetty’s WebAppContext wants to be configured with a directory that contains the web application. I’ve asked on the Jetty mailing list for some tips.

I choose redMine at random for my experiments. I couldn’t get redMine to create its database with Apache Derby, due to some issue with DATEs and TIMESTAMPs. Getting this to work would be great, since then you have a server-in-JAR that is completely standalone.

However, everything worked fine with MySQL over JDBC. Running redMine under JRuby using WEBrick worked great (after a minor workaround for JRUBY-964), but I had an issue with it failing to start when deployed as a WAR, due to some problem with the IConv.open method. I’ll investigate this a bit more.

Along the way, I submitted two JRuby bugs (JRUBY-954, JRUBY-964), commented on JRUBY-925 and produced a simple test case for JRUBY-956, which is a bug the Mingle folks ran into. I also did some debugging of JRUBY-822.

Along the way, this Rails Cheat Sheet came in handy, since I haven’t looked at Rails since 2005.