|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
Grails 1.2-M4 and SpringSecurity - Issue using eventsHello all,
I've just upgraded my app from 1.2-M2 to 1.2-M4 and noticed a little bug (probably). I'm using a simple test event here to log all login attemps in the application. Simple as this. onAbstractAuthenticationFailureEvent = { e, appCtx -> def principal = e.getAuthentication().getPrincipal() if (principal) { new LoginAttemp(username: principal, success: false).save() } } In Grails 1.2-M2 it was working well withou any issue, just upgraded to 1.2-M4 and when user tries to log in (and trigger the event), I get an exception org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here at org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63) at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:574) at org.codehaus.groovy.grails.orm.hibernate.validation.HibernateDomainClassValidator.validate(HibernateDomainClassValidator.java:58) If I just comment the event everything works perfectly. Is there catch or workaround? Thanks! []s, Lucas Frare Teixeira .·. - lucastex@... - lucastex.com.br - blog.lucastex.com - twitter.com/lucastex |
|
|
Re: Grails 1.2-M4 and SpringSecurity - Issue using eventsI found when trying out the plugin in M3 that the core Spring interface org.springframework.context.ApplicationListener switched to using generics in 3.0 and this made the plugin's org.codehaus.groovy.grails.plugins.springsecurity.SecurityEventListener onApplicationEvent() signature invalid. Change
void onApplicationEvent(ApplicationEvent e) { to void onApplicationEvent(e) { and see if that helps. Burt > Hello all, > > I've just upgraded my app from 1.2-M2 to 1.2-M4 and noticed a little bug > (probably). > I'm using a simple test event here to log all login attemps in the > application. > > Simple as this. > > onAbstractAuthenticationFailureEvent = { e, appCtx -> > def principal = e.getAuthentication().getPrincipal() > if (principal) { > new LoginAttemp(username: principal, success: false).save() > } > } > > In Grails 1.2-M2 it was working well withou any issue, just upgraded to > 1.2-M4 and when user tries to log in (and trigger the event), I get an > exception > > org.hibernate.HibernateException: No Hibernate Session bound to thread, and > configuration does not allow creation of non-transactional one here > at > org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63) > at > org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:574) > at > org.codehaus.groovy.grails.orm.hibernate.validation.HibernateDomainClassValidator.validate(HibernateDomainClassValidator.java:58) > > If I just comment the event everything works perfectly. > > Is there catch or workaround? > > Thanks! > > []s, > > > Lucas Frare Teixeira .·. > - lucastex@... > - lucastex.com.br > - blog.lucastex.com > - twitter.com/lucastex > |
|
|
Re: Grails 1.2-M4 and SpringSecurity - Issue using eventsHello Burt,
In my case, I'm using closures directly inside SecurityConfig.groovy instead of implementing my own SecurityEventListener. The closure definition is only onAbstractAuthenticationFailureEvent = { e, appCtx -> Can I change something this way instead of implementing by own EventListener (to be able to change as you said) ? Thanks a lot, []s, Lucas Frare Teixeira .·. - lucastex@... - lucastex.com.br - blog.lucastex.com - twitter.com/lucastex On Sat, Nov 7, 2009 at 1:39 PM, Burt Beckwith <burt@...> wrote: I found when trying out the plugin in M3 that the core Spring interface org.springframework.context.ApplicationListener switched to using generics in 3.0 and this made the plugin's org.codehaus.groovy.grails.plugins.springsecurity.SecurityEventListener onApplicationEvent() signature invalid. Change |
|
|
Re: Grails 1.2-M4 and SpringSecurity - Issue using eventsRight, but those closures are triggered by the plugin's org.codehaus.groovy.grails.plugins.springsecurity.SecurityEventListener (in its src/groovy), so I think it's what's broken.
Burt > Hello Burt, > > In my case, I'm using closures directly inside SecurityConfig.groovy instead > of implementing my own SecurityEventListener. The closure definition is only > *onAbstractAuthenticationFailureEvent = { e, appCtx ->* > > Can I change something this way instead of implementing by own EventListener > (to be able to change as you said) ? > > Thanks a lot, > > []s, > > > Lucas Frare Teixeira .·. > - lucastex@... > - lucastex.com.br > - blog.lucastex.com > - twitter.com/lucastex > > > On Sat, Nov 7, 2009 at 1:39 PM, Burt Beckwith <burt@...> wrote: > > > I found when trying out the plugin in M3 that the core Spring interface > > org.springframework.context.ApplicationListener switched to using generics > > in 3.0 and this made the plugin's > > org.codehaus.groovy.grails.plugins.springsecurity.SecurityEventListener > > onApplicationEvent() signature invalid. Change > > > > void onApplicationEvent(ApplicationEvent e) { > > > > to > > > > void onApplicationEvent(e) { > > > > and see if that helps. > > > > Burt > > > > > Hello all, > > > > > > I've just upgraded my app from 1.2-M2 to 1.2-M4 and noticed a little bug > > > (probably). > > > I'm using a simple test event here to log all login attemps in the > > > application. > > > > > > Simple as this. > > > > > > onAbstractAuthenticationFailureEvent = { e, appCtx -> > > > def principal = e.getAuthentication().getPrincipal() > > > if (principal) { > > > new LoginAttemp(username: principal, success: false).save() > > > } > > > } > > > > > > In Grails 1.2-M2 it was working well withou any issue, just upgraded to > > > 1.2-M4 and when user tries to log in (and trigger the event), I get an > > > exception > > > > > > org.hibernate.HibernateException: No Hibernate Session bound to thread, > > and > > > configuration does not allow creation of non-transactional one here > > > at > > > > > org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63) > > > at > > > > > org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:574) > > > at > > > > > org.codehaus.groovy.grails.orm.hibernate.validation.HibernateDomainClassValidator.validate(HibernateDomainClassValidator.java:58) > > > > > > If I just comment the event everything works perfectly. > > > > > > Is there catch or workaround? > > > > > > Thanks! > > > > > > []s, > > > > > > > > > Lucas Frare Teixeira .·. > > > - lucastex@... > > > - lucastex.com.br > > > - blog.lucastex.com > > > - twitter.com/lucastex > > > > > > |
|
|
Re: Grails 1.2-M4 and SpringSecurity - Issue using eventsOh, ok! ;)
But i've changed but haven't changed the error. Same thing. The full stack is written here: http://pastie.org/688004 (to not flood here). Thanks again! []s, Lucas Frare Teixeira .·. - lucastex@... - lucastex.com.br - blog.lucastex.com - twitter.com/lucastex On Sat, Nov 7, 2009 at 2:39 PM, Burt Beckwith <burt@...> wrote: Right, but those closures are triggered by the plugin's org.codehaus.groovy.grails.plugins.springsecurity.SecurityEventListener (in its src/groovy), so I think it's what's broken. |
|
|
Re: Grails 1.2-M4 and SpringSecurity - Issue using eventsOk, I'll take a closer look.
Burt > Oh, ok! ;) > > But i've changed but haven't changed the error. Same thing. > The full stack is written here: http://pastie.org/688004 (to not flood > here). > > Thanks again! > > []s, > > Lucas Frare Teixeira .·. > - lucastex@... > - lucastex.com.br > - blog.lucastex.com > - twitter.com/lucastex > > > On Sat, Nov 7, 2009 at 2:39 PM, Burt Beckwith <burt@...> wrote: > > > Right, but those closures are triggered by the plugin's > > org.codehaus.groovy.grails.plugins.springsecurity.SecurityEventListener (in > > its src/groovy), so I think it's what's broken. > > > > Burt > > > > > Hello Burt, > > > > > > In my case, I'm using closures directly inside SecurityConfig.groovy > > instead > > > of implementing my own SecurityEventListener. The closure definition is > > only > > > *onAbstractAuthenticationFailureEvent = { e, appCtx ->* > > > > > > Can I change something this way instead of implementing by own > > EventListener > > > (to be able to change as you said) ? > > > > > > Thanks a lot, > > > > > > []s, > > > > > > > > > Lucas Frare Teixeira .·. > > > - lucastex@... > > > - lucastex.com.br > > > - blog.lucastex.com > > > - twitter.com/lucastex > > > > > > > > > On Sat, Nov 7, 2009 at 1:39 PM, Burt Beckwith <burt@...> > > wrote: > > > > > > > I found when trying out the plugin in M3 that the core Spring interface > > > > org.springframework.context.ApplicationListener switched to using > > generics > > > > in 3.0 and this made the plugin's > > > > org.codehaus.groovy.grails.plugins.springsecurity.SecurityEventListener > > > > onApplicationEvent() signature invalid. Change > > > > > > > > void onApplicationEvent(ApplicationEvent e) { > > > > > > > > to > > > > > > > > void onApplicationEvent(e) { > > > > > > > > and see if that helps. > > > > > > > > Burt > > > > > > > > > Hello all, > > > > > > > > > > I've just upgraded my app from 1.2-M2 to 1.2-M4 and noticed a little > > bug > > > > > (probably). > > > > > I'm using a simple test event here to log all login attemps in the > > > > > application. > > > > > > > > > > Simple as this. > > > > > > > > > > onAbstractAuthenticationFailureEvent = { e, appCtx -> > > > > > def principal = e.getAuthentication().getPrincipal() > > > > > if (principal) { > > > > > new LoginAttemp(username: principal, success: > > false).save() > > > > > } > > > > > } > > > > > > > > > > In Grails 1.2-M2 it was working well withou any issue, just upgraded > > to > > > > > 1.2-M4 and when user tries to log in (and trigger the event), I get > > an > > > > > exception > > > > > > > > > > org.hibernate.HibernateException: No Hibernate Session bound to > > thread, > > > > and > > > > > configuration does not allow creation of non-transactional one here > > > > > at > > > > > > > > > > > org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63) > > > > > at > > > > > > > > > > > org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:574) > > > > > at > > > > > > > > > > > org.codehaus.groovy.grails.orm.hibernate.validation.HibernateDomainClassValidator.validate(HibernateDomainClassValidator.java:58) > > > > > > > > > > If I just comment the event everything works perfectly. > > > > > > > > > > Is there catch or workaround? > > > > > > > > > > Thanks! > > > > > > > > > > []s, > > > > > > > > > > > > > > > Lucas Frare Teixeira .·. > > > > > - lucastex@... > > > > > - lucastex.com.br > > > > > - blog.lucastex.com > > > > > - twitter.com/lucastex > > > > > > > > > > > > > > > |
|
|
Re: Grails 1.2-M4 and SpringSecurity - Issue using eventsWorked fine for me. I have an M3 app that I upgraded to M4 and added in an onAbstractAuthenticationFailureEvent closure that just logs a message, so I don't think it's an issue with Spring Security. Try wrapping the save call in a transaction:
onAbstractAuthenticationFailureEvent = { e, appCtx -> def principal = e.authentication.principal if (principal) { LoginAttemp.withTransaction { s -> new LoginAttemp(username: principal, success: false).save() } } } Burt > Ok, I'll take a closer look. > > Burt > > > Oh, ok! ;) > > > > But i've changed but haven't changed the error. Same thing. > > The full stack is written here: http://pastie.org/688004 (to not flood > > here). > > > > Thanks again! > > > > []s, > > > > Lucas Frare Teixeira .·. > > - lucastex@... > > - lucastex.com.br > > - blog.lucastex.com > > - twitter.com/lucastex > > > > > > On Sat, Nov 7, 2009 at 2:39 PM, Burt Beckwith <burt@...> wrote: > > > > > Right, but those closures are triggered by the plugin's > > > org.codehaus.groovy.grails.plugins.springsecurity.SecurityEventListener (in > > > its src/groovy), so I think it's what's broken. > > > > > > Burt > > > > > > > Hello Burt, > > > > > > > > In my case, I'm using closures directly inside SecurityConfig.groovy > > > instead > > > > of implementing my own SecurityEventListener. The closure definition is > > > only > > > > *onAbstractAuthenticationFailureEvent = { e, appCtx ->* > > > > > > > > Can I change something this way instead of implementing by own > > > EventListener > > > > (to be able to change as you said) ? > > > > > > > > Thanks a lot, > > > > > > > > []s, > > > > > > > > > > > > Lucas Frare Teixeira .·. > > > > - lucastex@... > > > > - lucastex.com.br > > > > - blog.lucastex.com > > > > - twitter.com/lucastex > > > > > > > > > > > > On Sat, Nov 7, 2009 at 1:39 PM, Burt Beckwith <burt@...> > > > wrote: > > > > > > > > > I found when trying out the plugin in M3 that the core Spring interface > > > > > org.springframework.context.ApplicationListener switched to using > > > generics > > > > > in 3.0 and this made the plugin's > > > > > org.codehaus.groovy.grails.plugins.springsecurity.SecurityEventListener > > > > > onApplicationEvent() signature invalid. Change > > > > > > > > > > void onApplicationEvent(ApplicationEvent e) { > > > > > > > > > > to > > > > > > > > > > void onApplicationEvent(e) { > > > > > > > > > > and see if that helps. > > > > > > > > > > Burt > > > > > > > > > > > Hello all, > > > > > > > > > > > > I've just upgraded my app from 1.2-M2 to 1.2-M4 and noticed a little > > > bug > > > > > > (probably). > > > > > > I'm using a simple test event here to log all login attemps in the > > > > > > application. > > > > > > > > > > > > Simple as this. > > > > > > > > > > > > onAbstractAuthenticationFailureEvent = { e, appCtx -> > > > > > > def principal = e.getAuthentication().getPrincipal() > > > > > > if (principal) { > > > > > > new LoginAttemp(username: principal, success: > > > false).save() > > > > > > } > > > > > > } > > > > > > > > > > > > In Grails 1.2-M2 it was working well withou any issue, just upgraded > > > to > > > > > > 1.2-M4 and when user tries to log in (and trigger the event), I get > > > an > > > > > > exception > > > > > > > > > > > > org.hibernate.HibernateException: No Hibernate Session bound to > > > thread, > > > > > and > > > > > > configuration does not allow creation of non-transactional one here > > > > > > at > > > > > > > > > > > > > > org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63) > > > > > > at > > > > > > > > > > > > > > org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:574) > > > > > > at > > > > > > > > > > > > > > org.codehaus.groovy.grails.orm.hibernate.validation.HibernateDomainClassValidator.validate(HibernateDomainClassValidator.java:58) > > > > > > > > > > > > If I just comment the event everything works perfectly. > > > > > > > > > > > > Is there catch or workaround? > > > > > > > > > > > > Thanks! > > > > > > > > > > > > []s, > > > > > > > > > > > > > > > > > > Lucas Frare Teixeira .·. > > > > > > - lucastex@... > > > > > > - lucastex.com.br > > > > > > - blog.lucastex.com > > > > > > - twitter.com/lucastex > > > > > > > > > > > > > > > > > > > > > |
|
|
Re: Grails 1.2-M4 and SpringSecurity - Issue using eventsHello Burt!
Just changing the SecurityEventListener didn't make it happen, but adding the withTransaction solve my problem... Thanks a lot Burt! []s, Lucas Frare Teixeira .·. - lucastex@... - lucastex.com.br - blog.lucastex.com - twitter.com/lucastex On Sun, Nov 8, 2009 at 4:06 AM, Burt Beckwith <burt@...> wrote: Worked fine for me. I have an M3 app that I upgraded to M4 and added in an onAbstractAuthenticationFailureEvent closure that just logs a message, so I don't think it's an issue with Spring Security. Try wrapping the save call in a transaction: |
| Free embeddable forum powered by Nabble | Forum Help |