Tuesday, October 19, 2010

Spring security core build path problem

First time trying Grails 1.3.5, creating a new test project. Installing spring-security-core plugin (following the tutorial) and then importing the project to STS 2.5M1 and letting STS know that it's a Grail project (Configure->Convert to a Grails project... something like this). I was hoping for an easy ride here, expecting no errors since I haven't add anything, all are auto generated.

But as usual, with programming world, there ain't no such things as a bug/error free codes. I got compile errors like this in my LoginController.groovy.

I know that I'm missing org.springframework.security.core-3.0.3.RELEASE.jar release in this case and the shortcut to solve this is just to add the jar to the project build path. But, is this going to happen for each plugin jar that I'm going to use? and anyway I don't like the solution to put the jar manually on the build path, it does look an ugly solution.

Fortunately I find a menu to refresh Grails' dependencies and the good news is it works for me, no more compile errors. Here's the context menu that pops up when I right click on my project:

I think this is caused by me adding the plugin from command prompt and then importing the project in STS. Imho, if the plugin is added thru STS' grails command prompt it should works without refreshing.

Hmm... just remember that this is similar to when I add a new file to my project using my file manager. Eclipse can't see the file, until I refresh the project.