|
Hi everybody. I can't get Spring Security to work. I get the following error when I submit the login form:
java.lang.RuntimeException: The specified user domain class 'Person' is not a domain class at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77) at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:71) at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:81) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:52) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:198) at org.codehaus.groovy.grails.plugins.springsecurity.GormUserDetailsService.loadUserByUsername(GormUserDetailsService.groovy:53) at org.codehaus.groovy.grails.plugins.springsecurity.GrailsUserDetailsService$loadUserByUsername.callCurrent(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:153) at org.codehaus.groovy.grails.plugins.springsecurity.GormUserDetailsService.loadUserByUsername(GormUserDetailsService.groovy:76) at org.springframework.security.authentication.dao.DaoAuthenticationProvider.retrieveUser(DaoAuthenticationProvider.java:86) at org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:129) at org.springframework.security.authentication.ProviderManager.doAuthentication(ProviderManager.java:130) at org.springframework.security.authentication.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:48) at org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter.attemptAuthentication(UsernamePasswordAuthenticationFilter.java:97) ... 2011-11-14 19:21:41,794 [http-8080-1] ERROR [/SpringSecurityExample].[grails-errorhandler] - Servlet.service() for servlet grails-errorhandler threw exception java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request. at org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes(RequestContextHolder.java:131) at org.codehaus.groovy.grails.web.util.WebUtils.retrieveGrailsWebRequest(WebUtils.java:497) at org.codehaus.groovy.grails.plugins.springsecurity.AnnotationFilterInvocationDefinition.determineUrl(AnnotationFilterInvocationDefinition.java:64) at org.codehaus.groovy.grails.plugins.springsecurity.AbstractFilterInvocationDefinition.getAttributes(AbstractFilterInvocationDefinition.java:79) at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:171) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:106) ... 2011-11-14 19:21:41,839 [http-8080-1] ERROR [Tomcat].[localhost] - Exception Processing ErrorPage[errorCode=500, location=/grails-errorhandler] java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request. at org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes(RequestContextHolder.java:131) at org.codehaus.groovy.grails.web.util.WebUtils.retrieveGrailsWebRequest(WebUtils.java:497) at org.codehaus.groovy.grails.plugins.springsecurity.AnnotationFilterInvocationDefinition.determineUrl(AnnotationFilterInvocationDefinition.java:64) at org.codehaus.groovy.grails.plugins.springsecurity.AbstractFilterInvocationDefinition.getAttributes(AbstractFilterInvocationDefinition.java:79) at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:171) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:106) ... I don't have a 'Person' domain class. I searched it all over my project and nothing. I have an Usuario domain class which is extending the SecUser class. Why is this error being produced? Please help me. |
|
You need to set
grails.plugins.springsecurity.userLookup.userDomainClassName (and a few other ones). The default config if you dont set it is just 'Person', which is why you get this error, as the userdetails service tries to pull in that class. The s2-quickstart script should have added lines to your config, if you removed those put them back in (or do a good old fashioned RTFM, security shouldnt be hackey-sacked into your project ;-) ). -Oliver On Tue, Nov 15, 2011 at 1:39 AM, orion_mjcl <[hidden email]> wrote: > Hi everybody. I can't get Spring Security to work. I get the following error > when I submit the login form: > > java.lang.RuntimeException: The specified user domain class 'Person' is not > a domain class > at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) > at > sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) > at > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) > at java.lang.reflect.Constructor.newInstance(Constructor.java:513) > at > org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77) > at > org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:71) > at > org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:81) > at > org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:52) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:198) > at > org.codehaus.groovy.grails.plugins.springsecurity.GormUserDetailsService.loadUserByUsername(GormUserDetailsService.groovy:53) > at > org.codehaus.groovy.grails.plugins.springsecurity.GrailsUserDetailsService$loadUserByUsername.callCurrent(Unknown > Source) > at > org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:153) > at > org.codehaus.groovy.grails.plugins.springsecurity.GormUserDetailsService.loadUserByUsername(GormUserDetailsService.groovy:76) > at > org.springframework.security.authentication.dao.DaoAuthenticationProvider.retrieveUser(DaoAuthenticationProvider.java:86) > at > org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:129) > at > org.springframework.security.authentication.ProviderManager.doAuthentication(ProviderManager.java:130) > at > org.springframework.security.authentication.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:48) > at > org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter.attemptAuthentication(UsernamePasswordAuthenticationFilter.java:97) > ... > 2011-11-14 19:21:41,794 [http-8080-1] ERROR > [/SpringSecurityExample].[grails-errorhandler] - Servlet.service() for > servlet grails-errorhandler threw exception > java.lang.IllegalStateException: No thread-bound request found: Are you > referring to request attributes outside of an actual web request, or > processing a request outside of the originally receiving thread? If you are > actually operating within a web request and still receive this message, your > code is probably running outside of DispatcherServlet/DispatcherPortlet: In > this case, use RequestContextListener or RequestContextFilter to expose the > current request. > at > org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes(RequestContextHolder.java:131) > at > org.codehaus.groovy.grails.web.util.WebUtils.retrieveGrailsWebRequest(WebUtils.java:497) > at > org.codehaus.groovy.grails.plugins.springsecurity.AnnotationFilterInvocationDefinition.determineUrl(AnnotationFilterInvocationDefinition.java:64) > at > org.codehaus.groovy.grails.plugins.springsecurity.AbstractFilterInvocationDefinition.getAttributes(AbstractFilterInvocationDefinition.java:79) > at > org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:171) > at > org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:106) > ... > 2011-11-14 19:21:41,839 [http-8080-1] ERROR [Tomcat].[localhost] - > Exception Processing ErrorPage[errorCode=500, location=/grails-errorhandler] > java.lang.IllegalStateException: No thread-bound request found: Are you > referring to request attributes outside of an actual web request, or > processing a request outside of the originally receiving thread? If you are > actually operating within a web request and still receive this message, your > code is probably running outside of DispatcherServlet/DispatcherPortlet: In > this case, use RequestContextListener or RequestContextFilter to expose the > current request. > at > org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes(RequestContextHolder.java:131) > at > org.codehaus.groovy.grails.web.util.WebUtils.retrieveGrailsWebRequest(WebUtils.java:497) > at > org.codehaus.groovy.grails.plugins.springsecurity.AnnotationFilterInvocationDefinition.determineUrl(AnnotationFilterInvocationDefinition.java:64) > at > org.codehaus.groovy.grails.plugins.springsecurity.AbstractFilterInvocationDefinition.getAttributes(AbstractFilterInvocationDefinition.java:79) > at > org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:171) > at > org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:106) > ... > > I don't have a 'Person' domain class. I searched it all over my project and > nothing. I have an Usuario domain class which is extending the SecUser > class. Why is this error being produced? > > Please help me. > > -- > View this message in context: http://grails.1312388.n4.nabble.com/Having-problems-with-Spring-Security-plugin-tp4041437p4041437.html > Sent from the Grails - user mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > -- ***** Oliver Tynes Developer Uni CIPR -- www.cipr.uni.no 55588266 ***** --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by orion_mjcl
Did you configure the Config value
grails.plugins.springsecurity.userLookup.userDomainClassName so that spring security is aware that you have a different user domain class? Check http://burtbeckwith.github.com/grails-spring-security-core/docs/manual/guide/single.html#4%20Required%20and%20Optional%20Domain%20Classes Cheers, Nick http://www.spotdiving.com On Tue, Nov 15, 2011 at 11:39 AM, orion_mjcl <[hidden email]> wrote: > Hi everybody. I can't get Spring Security to work. I get the following error > when I submit the login form: > > java.lang.RuntimeException: The specified user domain class 'Person' is not > a domain class > at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) > at > sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) > at > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) > at java.lang.reflect.Constructor.newInstance(Constructor.java:513) > at > org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77) > at > org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:71) > at > org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:81) > at > org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:52) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:198) > at > org.codehaus.groovy.grails.plugins.springsecurity.GormUserDetailsService.loadUserByUsername(GormUserDetailsService.groovy:53) > at > org.codehaus.groovy.grails.plugins.springsecurity.GrailsUserDetailsService$loadUserByUsername.callCurrent(Unknown > Source) > at > org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:153) > at > org.codehaus.groovy.grails.plugins.springsecurity.GormUserDetailsService.loadUserByUsername(GormUserDetailsService.groovy:76) > at > org.springframework.security.authentication.dao.DaoAuthenticationProvider.retrieveUser(DaoAuthenticationProvider.java:86) > at > org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:129) > at > org.springframework.security.authentication.ProviderManager.doAuthentication(ProviderManager.java:130) > at > org.springframework.security.authentication.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:48) > at > org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter.attemptAuthentication(UsernamePasswordAuthenticationFilter.java:97) > ... > 2011-11-14 19:21:41,794 [http-8080-1] ERROR > [/SpringSecurityExample].[grails-errorhandler] - Servlet.service() for > servlet grails-errorhandler threw exception > java.lang.IllegalStateException: No thread-bound request found: Are you > referring to request attributes outside of an actual web request, or > processing a request outside of the originally receiving thread? If you are > actually operating within a web request and still receive this message, your > code is probably running outside of DispatcherServlet/DispatcherPortlet: In > this case, use RequestContextListener or RequestContextFilter to expose the > current request. > at > org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes(RequestContextHolder.java:131) > at > org.codehaus.groovy.grails.web.util.WebUtils.retrieveGrailsWebRequest(WebUtils.java:497) > at > org.codehaus.groovy.grails.plugins.springsecurity.AnnotationFilterInvocationDefinition.determineUrl(AnnotationFilterInvocationDefinition.java:64) > at > org.codehaus.groovy.grails.plugins.springsecurity.AbstractFilterInvocationDefinition.getAttributes(AbstractFilterInvocationDefinition.java:79) > at > org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:171) > at > org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:106) > ... > 2011-11-14 19:21:41,839 [http-8080-1] ERROR [Tomcat].[localhost] - > Exception Processing ErrorPage[errorCode=500, location=/grails-errorhandler] > java.lang.IllegalStateException: No thread-bound request found: Are you > referring to request attributes outside of an actual web request, or > processing a request outside of the originally receiving thread? If you are > actually operating within a web request and still receive this message, your > code is probably running outside of DispatcherServlet/DispatcherPortlet: In > this case, use RequestContextListener or RequestContextFilter to expose the > current request. > at > org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes(RequestContextHolder.java:131) > at > org.codehaus.groovy.grails.web.util.WebUtils.retrieveGrailsWebRequest(WebUtils.java:497) > at > org.codehaus.groovy.grails.plugins.springsecurity.AnnotationFilterInvocationDefinition.determineUrl(AnnotationFilterInvocationDefinition.java:64) > at > org.codehaus.groovy.grails.plugins.springsecurity.AbstractFilterInvocationDefinition.getAttributes(AbstractFilterInvocationDefinition.java:79) > at > org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:171) > at > org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:106) > ... > > I don't have a 'Person' domain class. I searched it all over my project and > nothing. I have an Usuario domain class which is extending the SecUser > class. Why is this error being produced? > > Please help me. > > -- > View this message in context: http://grails.1312388.n4.nabble.com/Having-problems-with-Spring-Security-plugin-tp4041437p4041437.html > Sent from the Grails - user mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
Thank you all. I overcame that error but I'm still having a problem. I can't login!
I'm having the "Sorry, we were not able to find a user with that username and password." message when I enter my username and password. Here's my BootStrap content:
class BootStrap { def springSecurityService def init = { servletContext -> def userRole = SecRole.findByAuthority('ROLE_USER') ?: new SecRole(authority: 'ROLE_USER').save(failOnError: true) def adminRole = SecRole.findByAuthority('ROLE_ADMIN') ?: new SecRole(authority: 'ROLE_ADMIN').save(failOnError: true) def adminUser = SecUser.findByUsername('admin') ?: new SecUser( username: 'admin', password: springSecurityService.encodePassword('admin'), enabled: true).save(failOnError: true) if (!SecUserSecRole.findBySecUserAndSecRole(adminUser, adminRole)) { SecUserSecRole.create adminUser, adminRole } } def destroy = { } } |
|
What does your Person class look like? We recently had an issue where we defined a guid on the User (Person) class and hit a similar issue, everything looked like it was setup perfect but we were unable to log in.
Cheers, Daniel On Mon, Nov 14, 2011 at 6:58 PM, orion_mjcl <[hidden email]> wrote: Thank you all. I overcame that error but I'm still having a problem. I can't |
|
Thank you for answering Daniel. I'm not using any Person class. I had an Usuario domain class which extended SecUser domain class but I deleted it because I thought that there was the problem. I'm using just the SecUser class as you can see in the following line of code:
def adminUser = SecUser.findByUsername('admin') ?: new SecUser( username: 'admin', password: springSecurityService.encodePassword('admin'), enabled: true).save(failOnError: true) This is the content of SecUser: package org.example class SecUser { transient springSecurityService String username String password boolean enabled boolean accountExpired boolean accountLocked boolean passwordExpired static constraints = { username blank: false, unique: true password blank: false } static mapping = { password column: '`password`' } Set<SecRole> getAuthorities() { SecUserSecRole.findAllBySecUser(this).collect { it.secRole } as Set } def beforeInsert() { encodePassword() } def beforeUpdate() { if (isDirty('password')) { encodePassword() } } protected void encodePassword() { password = springSecurityService.encodePassword(password) } } |
|
You don't need to use the password encode service anymore, as it's called directly now if I recall. Set the value directly.
On Nov 14, 2011, at 6:40 PM, orion_mjcl <[hidden email]> wrote: > Thank you for answering Daniel. I'm not using any Person class. I had an > Usuario domain class which extended SecUser domain class but I deleted it > because I thought that there was the problem. I'm using just the SecUser > class as you can see in the following line of code: > > def adminUser = SecUser.findByUsername('admin') ?: new SecUser( > username: 'admin', > password: springSecurityService.encodePassword('admin'), > enabled: true).save(failOnError: true) > > This is the content of SecUser: > > package org.example > > class SecUser { > > transient springSecurityService > > String username > String password > boolean enabled > boolean accountExpired > boolean accountLocked > boolean passwordExpired > > static constraints = { > username blank: false, unique: true > password blank: false > } > > static mapping = { > password column: '`password`' > } > > Set<SecRole> getAuthorities() { > SecUserSecRole.findAllBySecUser(this).collect { it.secRole } as Set > } > > def beforeInsert() { > encodePassword() > } > > def beforeUpdate() { > if (isDirty('password')) { > encodePassword() > } > } > > protected void encodePassword() { > password = springSecurityService.encodePassword(password) > } > } > > > -- > View this message in context: http://grails.1312388.n4.nabble.com/Having-problems-with-Spring-Security-plugin-tp4041437p4041665.html > Sent from the Grails - user mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
This post has NOT been accepted by the mailing list yet.
I've received similar error, resolve it by moving :
grails.plugins.springsecurity.userLookup.userDomainClassName grails.plugins.springsecurity.userLookup.authorityJoinClassName grails.plugins.springsecurity.authority.className to top of Config.groovy file |
|
This post has NOT been accepted by the mailing list yet.
I was having the same issue as the original poster, and moving the spring security config settings to the top of Config.groovy resolved the issue. Thanks, Neels!
|
|
This post has NOT been accepted by the mailing list yet.
In reply to this post by orion_mjcl
I traced it back to a validation problem in my UserDomainClass configured on grails.plugins.springsecurity.userLookup.userDomainClassName
|
|
This post has NOT been accepted by the mailing list yet.
forgot to mention in the previous post that this was a similar problem due to an additional property that I introduced in my UserDomainClass
|
| Powered by Nabble | Edit this page |
