Skip navigation

Category Archives: code

I ran across an issue today where my Grails app was stuck in an infinite loop “compiling” on startup.

Command line symptons revealed the following:

Running Grails application..
Server running. Browse to http://localhost:8080/foo
[groovyc] Compiling 1 source file to /Users/cs44/.grails/1.1/projects/foo/classes
[groovyc] Compiling 1 source file to /Users/cs44/.grails/1.1/projects/foo/classes
Running Grails application..

Over and over….

Turns out I had a compiliaton failure of a groovy file in my “/src/groovy” directory. It sure would have been nice to ACTUALLY know of this compilation error as it happened. That said, the only way to find the culprit file is change to your grails class directory, which on my OS X box is the following: ~/.grails/1.1/projects/watch/classes

Next up — in a new shell, you’ll want to start the application, forcing the infinite compilation loop. While the app is failing to startup, run the following command in your classes directory: find . -name “*class” -ls

This will list all .class files, including our failed file(s), plus an “ls” style directory listing. From here examine the last modifed date and you should find your culprit.

Remove said file and recompile.

Hope that helps someone! I certainly chased my tail for bit…


If you’re using terminal in conjunction with Maven, the easiest way to increase the heap size on your JVM using OS X is as follows:

1) Using Sudo mode, open up you bash profile (mine lives at ‘/etc/profile’)
2) Add “MAVEN_OPTS=’-Xms256M -Xmx512M’; export MAVEN_OPTS;”
3) Save your profile.
4) Open a new shell and ensure the MAVEN_OPTS var exists by using the “set” command and searching for MAVEN_OPTS.
5) Enjoy your java.


By default OS X Leopard (10.5.5) ships with Java JDK 1.5 as the default JDK. This is fine until you actually need to compile an app dependent on 1.6, or even run an app that demands the latest API for JRuby or even Glassfish.

If you search the web for “OS X Java JDK 1.6” you’re likely to get blog posts related to the “SoyLatte” release of JDK 1.6. These blogs generally provide shell commands and environment setups that are required to compile the “SoyLatte” build of Java 1.6 for OS X. Aside from the lengthy process description, the real frustration comes in the contradictory experiences posted in the comments of said blogs. Quickly, the “upgrade” becomes disheartening.

There’s hope! (And it’s surprisingly easy…)

From Finder simply open “/Applications/Utilities/Java/Java Preferences” and drag “1.6” to the top of the list. You should now be able to confirm JDK 1.6 from the Terminal by typing “java -version”. You should see “1.6” (or something at least starting in 1.6.)

Now for Maven. The tricky part lies in your environmental $JAVA_HOME variable being set to the JDK 1.5 path. In the terminal, locate your Bash profile. (Mine lives at “/etc/profile”.) You’ll need to run “sudo” to edit and save the file.

Inside profile, you should have the following line as required by Maven:
JAVA_HOME=/Library/Java/Home; export JAVA_HOME;

If you do not see this line – I’m not sure this post applies to you…

Anyhow, “/Library/Java/Home” is a symbolic link that is still pointing to the JDK 1.5 “bin”, which prevents Maven from running the appropriate Java version. (This, of course, is correct if you’re forcing JDK versions through Maven.)

You’ll now want to alter the $JAVA_HOME variable to the following:
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home; export JAVA_HOME;

Save your profile, open a new Terminal session — that should do it. Via the OS X preferences pane, you’ve directed OS X to the JDK 1.6.  While through the $JAVA_HOME variable, you’ve pointed Maven to the appropriate JDK.

Hope that helps.