I’ve recently been reading ‘The Definitive Guide to Grails’ Second Edition, by Graeme Rocher and Jeff Brown.
It made sense to try and work my way through the examples in a practical manner as well as read the book, so I downloaded Grails 1.3 (the book suggests 1.1, but what the hell) and followed various installation instructions. The instructions on the Grails site and in the book are very similar, so that sounded promising.
I followed the first example, you create a grails-app called gTunes, you create a controller called StoreController, you add one line of code to the controller and two lines of code to a unit test, you run the unit test and it confirms that the response it’s expecting is equal to what the controller index is generating. So far so good.
You’re then supposed to run grails run-app, which I did… The book then suggests i’ll eventually get a suggestion that the application has been started, I never did.
I tried the browser link I was expecting anyway and it just sat there waiting for data.
I looked at netstat, it confirmed that there was a Java process listening on port 8080.
I could telnet to port 8080, but couldn’t get any response from the server.
Top suggested the process was using 100% CPU and the memory usage was slowly increasing. After about an hour, the memory usage went from about 256M up to 1G. Something was clearly wrong. The application was doing something, but what?!
I couldn’t find any obvious way of debugging what grails was doing, so I eventually reverted to trusty strace.
To my amazement, after the output whizzed by very quickly and unreadable, it slowed slightly and I could see lots and lots of stat’s against files on the filestystem. Stopping the process and then lokoing back through my scrollback, it seemed to be stat’ing EVERY file on the filesystem?!
Further investigation eventually suggested that the java process had the argument
--classpath /
It’s the only reference of / I could find anywhere, so overriding it in the current shell to . , my grails app started.
It turns out that I set my CLASSPATH to / for some other applications (dont’ ask). But it seems that grails parses every file on your classpath, which was causing my problem!