Spring Secutiry (ACEGI) Plugin and Favicon Permissions

Here’s a quick gotcha for you. You set up a favicon in the root of your web app, as is the convention, and when you log in you are redirected to a picture of your favicon or you are asked to download it… Weird.

Odds on you’ve installed the Spring Security plugin and forgotten to give permission to the favicon file in the root and the result is that on login Spring Security redirects you to the first restricted item that was requested by the browser – the favicon.

The solution? Easy, set the favicon path to IS_AUTHENTICATED_ANONYMOUSLY in your SecurityConfig.groovy (or database):

controllerAnnotationStaticRules = [
    '/favicon.ico' : ['IS_AUTHENTICATED_ANONYMOUSLY'],

Sending Asynchronous HTML Email in Grails with ActiveMQ, JMS and Gmail

Sending email asynchronously is an essential part of most Web applications and there are many ways in which to implement it. In this post I’ve chosen to demonstrate how to set up JMS, ActiveMQ and Gmail with the Grails Mail plugin to provide asynchronous email capabilities while only having to write a few lines of code, all thanks to some great plugins. I’ll also show the fantastic Grails Mail templating feature which uses GSP views to generate HTML emails along with a solution for one of the big bugs with it too!

Continue reading

Simple Aspects using Annotations in Grails

Aspect Oriented Programming is a concept which will be familiar to users of the Spring Framework as one of its core features. However, the details of how to get AOP working in Grails appear thin on the ground, so in this post I will show how to set up a simple aspect then configure and apply it using attributes. I will assume some familiarity with Spring AOP so I won’t explain the terminology or general concepts since they are exactly the sameĀ  in Java as they are in Grails. Continue reading

Updating the Logged in User with Acegi/Spring Security in Grails

Following on from my post on how to log in a user using the Grails Acegi/Spring Security plugin I stumbled into a new use for the same code when I tried to update a user’s own details while logged in. The security plugin caches the user’s domain object so any changes are not seen until the next login (wholly unhelpful when you’re trying to implement account management on a Website!).

Continue reading

When My Grails App Got Stuck in a Recompilation Loop

The first sign something was wrong was the JVM bombing out with a “java.lang.OutOfMemoryError: PermGen space” error. All I’d done was change a gsp, so I restarted and after a long wait the same thing happened and it was then I noticed that the compiler just kept recompiling 4 classes in a loop until the JVM bombed.

This had happened to me once before when I’d managed to set the time incorrectly on my PC so some of my files appeared to be modified in the future. However this time I’d not done anything of the sort.

Continue reading