The ‘R’ Sessions

(Image from

A few years ago whilst working on my MSc thesis I was heavily into R a statistical analysis package which has a functional language feel to it. My friend Marc Hasenbank, a few others and I ran a series of workshops for people wanting an introduction to R. I recently wanted to show this to someone so thought I would post a link. The code from the tutorials can be found here


Help JUnitMax play with Hamcrest 1.3

I have been working on converting our codebase to JUnit, with a secondary aim of trying out JUnitMax.

I ran the Max and quickly discovered that it failed when trying to execute assertions using the Hamcrest hasItems matcher.

The assertion looks something like:

NoSuchMethodException describeMismatch

This error frequently occurs because JUnit packages an older Version of the org.hamcrest.Matcher class which does not have the describeMismatch method.

I dug around a bit in the plugins directory in the eclipse install folder and found that it contains a junit-4.8.2.jar. Happy days I thought, I can simply do what I’ve been getting used to doing for a while and replace it with junit-dep-4.8.2.jar which does not contain the hamcrest classes.

Unfortunately this didn’t quite work. It turns out that you need to call it exactly the same junit-4.8.2.jar. I thought this was because there’s an entry in the MANIFEST.MF file but I tried to change it and that didn’t work too well.

Renaming the Jar file however works a treat and now I have full JUnitMax action on my box.

I’ve posted on the JUnitMax forums about the problem here.


Using TextMate with R


I’ve been using the R language for some years now but didn’t have it installed on my current machine.

TextMate is a great editor to use as it has a custom bundle that gives you syntax highlighting and executes commands for you in the R console.

To install the R bundle:

cd ~/Library/Application\ Support/TextMate/Bundles/
svn co

Then in TextMate choose Bundles->Bundle Editor->Reload Bundles.

There is one tweak I make which is that I like to press ⌘ + RETURN to execute the current selection in the R console. So edit the bundle and find in the commands and change the key. Also I like it to return back to text mate afterwards, so I add the following to the script:

-e ‘tell application “TextMate” to activate’ \

I also removed the line about setting the current dir. This was a little fiddly – I found that I had to make sure I selected the entire line and cut it then delete, making sure there are no end of line characters. So it looks like this:

# input is selection or document
if [[ ${#TM_DIRECTORY} -gt 0 ]]; then
osascript -e ‘on run(theCode)’ \
		  -e ‘tell application “R” to activate’ \
		  -e ‘tell application “R” to cmd (item 1 of theCode)’ \
		  -e ‘tell application “TextMate” to activate’ \
		  -e ‘end run’ — “$rawText” “$curDir”

All good.

UPDATE: 07/02/2011 – R now comes with a 64bit version so if you are on a macbook you can replace “R” in the code above with “R64”


Oracle Jdbc Driver fails to render Euro (€) when db is set to WE8MSWIN1252 encoding

We just spent a few glorious hours or so trawling the internet and writing old skool jdbc code, to discover this little beauty. Simply upgrade to of the jdbc driver and it goes away.

Thanks to this post we discovered our problem.

For the full details on the euro….

And if your really bored:


Hibernate Proxy InstantiationException

Changing entities to be lazy loaded led me to the following problem:

@OneToMany(fetch = FetchType.LAZY)
Caused by: org.hibernate.HibernateException: Javassist Enhancement failed: Thing
	at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(
	at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.getProxy(
	at org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(
	at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(
Caused by: java.lang.InstantiationException: Thing_$$_javassist_38
	at java.lang.Class.newInstance0(
	at java.lang.Class.newInstance(
	at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(

Thanks to Kristian I jumped straight to the problem. From the Hibernate docs:

Cat has a no-argument constructor. All persistent classes must have a default constructor (which can be non-public) so that Hibernate can instantiate them using Constructor.newInstance(). It is recommended that you have a default constructor with at least package visibility for runtime proxy generation in Hibernate.

This should probably read “It is essential….”

Anyway now everything is real lazy so happy days.