SpringSecurity error when deploying war file to Tomcat8
This is not a bug or anything in any framework, but it’s a very subtle error you can get when building a WAR file based on Grails 3.x using Spring Security plugin.
When annotating classes with @Secured annotation, it’s extremely important that you use the correct annotation.
You can actually use both :
And both will work fine, running grails from command line or in as self contained jar file, but if you make a war file out of your project and deploy it to tomcat, you will see an error like this:
Caused by: org.grails.core.exceptions.GrailsConfigurationException: Error configuring dynamic methods for plugin [springSecurityCore:3.0.3]: null
Caused by: java.lang.NullPointerException
So what’s happening here is that if you use the org.springframework annotation in your classes, it will not work, since it will expect it to be the grails.plugin version of the annotation. Very subtle indeed.