Grails 3 and spring-boot-starter-security

567 views
Skip to first unread message

Rafael Felini

unread,
Mar 19, 2015, 8:32:47 AM3/19/15
to grails-de...@googlegroups.com
Hi guys,

    I am trying to configure Spring Security via spring-boot-starter-security on Grails 3 and everything is going fine until I tried to enable @Secured annotations with @EnableGlobalMethodSecurity(securedEnabled = true) in my config class.

    After annotations are enabled this error come up:
Exception in thread "main" java.lang.IllegalArgumentException: Class name [org.grails.spring.aop.autoproxy.GroovyAwareAspectJAwareAdvisorAutoProxyCreator] is not a known auto-proxy creator class
        at org.springframework.aop.config.AopConfigUtils.findPriorityForClass(AopConfigUtils.java:140)
        at org.springframework.aop.config.AopConfigUtils.registerOrEscalateApcAsRequired(AopConfigUtils.java:113)
        at org.springframework.aop.config.AopConfigUtils.registerAutoProxyCreatorIfNecessary(AopConfigUtils.java:74)
 
    Anyone has an idea of what it might be?

   I'm using Grails 3 RC 2 and Java 8.

Thanks,
Rafael

Osaetin Evbuoma

unread,
May 6, 2015, 6:11:00 AM5/6/15
to grails-de...@googlegroups.com
Where you able to get a solution to this problem?

Rafael Felini

unread,
May 19, 2015, 1:19:06 PM5/19/15
to grails-de...@googlegroups.com
No, we ended up implementing an url based solution.


--
You received this message because you are subscribed to a topic in the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/grails-dev-discuss/hr1skz1RaZo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to grails-dev-disc...@googlegroups.com.
To post to this group, send email to grails-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/40ce40fb-c59f-4b99-adf3-6b4ab9bf1416%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bobby Warner

unread,
May 19, 2015, 5:05:35 PM5/19/15
to grails-de...@googlegroups.com

On Tuesday, May 19, 2015 at 12:19:06 PM UTC-5, Rafael Felini wrote:
No, we ended up implementing an url based solution.


On Wed, May 6, 2015 at 7:11 AM Osaetin Evbuoma <osaetin...@gmail.com> wrote:
Where you able to get a solution to this problem?


On Thursday, 19 March 2015 13:32:47 UTC+1, Rafael Felini wrote:
Hi guys,

    I am trying to configure Spring Security via spring-boot-starter-security on Grails 3 and everything is going fine until I tried to enable @Secured annotations with @EnableGlobalMethodSecurity(securedEnabled = true) in my config class.

    After annotations are enabled this error come up:
Exception in thread "main" java.lang.IllegalArgumentException: Class name [org.grails.spring.aop.autoproxy.GroovyAwareAspectJAwareAdvisorAutoProxyCreator] is not a known auto-proxy creator class
        at org.springframework.aop.config.AopConfigUtils.findPriorityForClass(AopConfigUtils.java:140)
        at org.springframework.aop.config.AopConfigUtils.registerOrEscalateApcAsRequired(AopConfigUtils.java:113)
        at org.springframework.aop.config.AopConfigUtils.registerAutoProxyCreatorIfNecessary(AopConfigUtils.java:74)
 
    Anyone has an idea of what it might be?

   I'm using Grails 3 RC 2 and Java 8.

Thanks,
Rafael

--
You received this message because you are subscribed to a topic in the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/grails-dev-discuss/hr1skz1RaZo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to grails-dev-discuss+unsub...@googlegroups.com.

Volnei Munhoz

unread,
Jun 9, 2015, 8:49:02 AM6/9/15
to grails-de...@googlegroups.com
Works fine for me too.

Arndt Teinert

unread,
Jun 20, 2015, 10:35:45 AM6/20/15
to grails-de...@googlegroups.com
Solved this by adding:


class
Application extends GrailsAutoConfiguration {
static void main(String[] args) {

Field field = AopConfigUtils.getDeclaredField("APC_PRIORITY_LIST")
field.setAccessible(true)
Object obj = field.get(null)
List<Class<?>> list = (List<Class<?>>) obj
list.add(GroovyAwareAspectJAwareAdvisorAutoProxyCreator.class)

GrailsApp.run(Application)
}

}

to the Grails Application class and by subclassing the @Secured enabling class:

/**
* To enable @Secured method security
*/
@EnableGlobalMethodSecurity(securedEnabled = true)
class MethodSecurityConfiguration extends GlobalMethodSecurityConfiguration {

Logger log = LoggerFactory.getLogger(MethodSecurityConfiguration.class)

MethodSecurityConfiguration() {
log.debug("MethodSecurityConfiguration initialized")
}
}


I know this is somehow a dirty trick and will fail if a security manager prevents access to the private static field.
I don't know which side effects this will cause.
May be there is a better way to "register" GroovyAwareAspectJAwareAdvisorAutoProxyCreator within the AopConfigUtils class.

It works for me.

Cheers

dunkelrot

unread,
Jun 27, 2015, 7:14:29 AM6/27/15
to grails-de...@googlegroups.com

changed it to:


class Application extends GrailsAutoConfiguration {

Closure doWithSpring() {{->
System.out.println("INFO: Extending APC_PRIORITY_LIST with GroovyAwareAspectJAwareAdvisorAutoProxyCreator")
// this is a work-around to get @Secured method security up and running
// looks like the GroovyAwareAspectJAwareAdvisorAutoProxyCreator is missing in AopConfigUtils
        Field field = AopConfigUtils.getDeclaredField("APC_PRIORITY_LIST")
field.setAccessible(true)
        List<Class<?>> list = (List<Class<?>>) field.get(null)
list.add(GroovyAwareAspectJAwareAdvisorAutoProxyCreator.class)
}}

static void main(String[] args) {
GrailsApp.run(Application)
}

}

to let this work in a servlet container.
Reply all
Reply to author
Forward
0 new messages