GStringImpl cannot be cast to java.lang.String
Last week, we got a nasty error in our application: java.lang.ClassCastException: org.codehaus.groovy.runtime.GStringImpl cannot be cast to java.lang.String The stacktrace was not helpful at all, and showed that the error was caused by a NullPointerException in Melody, which was a false message. After some searching around, we found the following code to be the culprit: render(view: 'index', model: ["${command.class.simpleName}": command) What happens here, is that a GString is used as a map key for rendering the model in the view....
read moreFriday Repost: Groovy’s @Immutable pitfalls
The Friday Repost series are copies from my earlier writings. Since I don’t want to loose them, and they might prove useful to others, I’m reposting them on this blog. Groovy 1.6 introduced some Groovy AST transformations like @Lazy, @Delegate and @Immutable, and there are more. This blog describes some pitfalls of using @Immutable, but to do that, a proper example of @Immutable seems well deserved. A first introduction @Immutable, like the name suggests, makes your classes immutable. This means that state changes from the...
read moreTesting Grails applications with Geb and JsTestDriver on a headless Bamboo CI server
In our project we are using two testing tools – Geb and JsTestDriver. Geb is a tool for functional testing of web applications and is basically a layer on the top of Selenium’s WebDriver so that the test you write are more groovy and more fun to write. JsTestDriver on the other hand is a tool for unit testing javascript in your project. Together with Sinon.JS which is a javascript mocking framework they give you an easy solution to get your javascript code unit tested. Both of the aforementioned frameworks need real browsers to...
read moreOur Grails Stats: but what are yours?
We’re currently working on a Grails project for over a year now, with, on average, around 8 people including testers. I thought it would be nice to share our project statistics, but I’m wondering how our statistics compare to yours. +----------------------+-------+-------+ | Name | Files | LOC | +----------------------+-------+-------+ | Controllers | 73 | 8394 | | Domain Classes | 122 | 4571 | | Jobs | 2 | 27 | | Services | ...
read moreFriday Repost: Groovy and Null
The Friday Repost series are copies from my earlier writings. Since I don’t want to loose them, and they might prove useful to others, I’m reposting them on this blog To start, I find it surprising that there’s so little information to be found about this topic. Maybe it’s just me, so let’s start with a test. If you pass all questions, you don’t win much, but then there’s no need to further read this blog I guess. So, without further ado, question 1. Question 1 What’s the result of the following...
read more
Recent Comments