Quantcast

Grails 3.1.2 and Spring Security Core won't save User

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Grails 3.1.2 and Spring Security Core won't save User

Chris Malan
On trying to save a user (called SecUser in the code) the following happens:
object references an unsaved transient instance - save the transient instance before flushing: security.SecUser. Stacktrace follows:
java.lang.reflect.InvocationTargetException: null
at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.groovy:53) ~[spring-security-core-3.0.3.jar:na]
at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.groovy:62) ~[spring-security-core-3.0.3.jar:na] etc. and
Caused by: org.springframework.beans.InvalidPropertyException: Invalid property 'authorities' of bean class [security.SecUser]: Getter for property 'authorities' threw exception; nested exception is java.lang.reflect.InvocationTargetException
at grails.transaction.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:96) ~[grails-core-3.1.2.jar:3.1.2]
 
This is caused by the middle line of this method in the User domain class generated by s2-quickstart:
 Set<SecRole> getAuthorities() {
SecUserSecRole.findAllBySecUser(this)*.secRole
}

Apparently the User is not persisted to the database at this stage.  The save is save(flush: true).

This method has been in the User domain class for some time and didn't create problems in earlier versions.  I thought maybe Hibernate is responsible and used Hibernate5 as well.  No change. 

It's a brand new project with only Spring Security Core added as a dependency and controllers and gsp pages generated.  If one tries to do it in Bootstrap.groovy the result is the same.

How can one get past this?

Thanks.

Chris

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/d16a6ab7-7c5e-47d6-9df5-9c5b9f8dfdf6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Grails 3.1.2 and Spring Security Core won't save User

Chris Malan
Some progress.  Changing getAuthorities to the following:

Set<SecRole> getAuthorities() {
if(!this.id){
println "The username: ${this.username}"
println "The password: ${this.password}"
}
return [] as Set
//SecUserSecRole.findAllBySecUser(this)*.secRole
}
sees to it that the user gets saved.  The printout is the following:
The username: jackson
The password: password
The username: jackson
The password: password
The username: jackson
The password: password
The username: jackson
The password: password
The username: jackson
The password: $2a$10$VRakfS5Zp2LUyLqf3zNunuBdlnmrfjTshK1fVV8i3JcnfmdiFVxk.
The username: jackson
The password: $2a$10$VRakfS5Zp2LUyLqf3zNunuBdlnmrfjTshK1fVV8i3JcnfmdiFVxk.
That's how many times this method gets called with one save() and one show().

Trying to save(flush: true) 'this' if it has no id (transient) results in a loop.  Top (Linux command) shows it uses two cores of the CPU fully and one partially.  Memory usage for just this process is about 25% at the time.   

So, this is far from a solution, but a pointer indicating the cause of the problem.  I'm very sure everyone will run into this using Grails 3.1.2 and Spring Security Core.  Give it time.  Grails 3.1.2 has been out only days.  This has to be resolved.

Hopefully the solution is easy.  

Chris

On Friday, March 4, 2016 at 12:24:18 AM UTC+11, Chris Malan wrote:
On trying to save a user (called SecUser in the code) the following happens:
object references an unsaved transient instance - save the transient instance before flushing: security.SecUser. Stacktrace follows:
java.lang.reflect.InvocationTargetException: null
at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.groovy:53) ~[spring-security-core-3.0.3.jar:na]
at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.groovy:62) ~[spring-security-core-3.0.3.jar:na] etc. and
Caused by: org.springframework.beans.InvalidPropertyException: Invalid property 'authorities' of bean class [security.SecUser]: Getter for property 'authorities' threw exception; nested exception is java.lang.reflect.InvocationTargetException
at grails.transaction.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:96) ~[grails-core-3.1.2.jar:3.1.2]
 
This is caused by the middle line of this method in the User domain class generated by s2-quickstart:
 Set<SecRole> getAuthorities() {
SecUserSecRole.findAllBySecUser(this)*.secRole
}

Apparently the User is not persisted to the database at this stage.  The save is save(flush: true).

This method has been in the User domain class for some time and didn't create problems in earlier versions.  I thought maybe Hibernate is responsible and used Hibernate5 as well.  No change. 

It's a brand new project with only Spring Security Core added as a dependency and controllers and gsp pages generated.  If one tries to do it in Bootstrap.groovy the result is the same.

How can one get past this?

Thanks.

Chris

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/6fb73f64-d049-4a50-b393-1d3a3a922cb6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Grails 3.1.2 and Spring Security Core won't save User

droggo
This post has NOT been accepted by the mailing list yet.

It’s a bug on 3.1.2. You can migrate to 3.1.3 or make this method `transient` or add `static transients = [‘authorities’]` to fix it.

See https://github.com/grails/grails-core/issues/9749 for details

 

From: Chris Malan [via Grails] [mailto:[hidden email]]
Sent: Friday, March 4, 2016 5:38 AM
To: droggo
Subject: Re: Grails 3.1.2 and Spring Security Core won't save User

 

Some progress.  Changing getAuthorities to the following:

 

        Set<SecRole> getAuthorities() {
                    if(!this.id){
                                println "The username: ${this.username}"
                                println "The password: ${this.password}"
                    }
                    return [] as Set
                    //SecUserSecRole.findAllBySecUser(this)*.secRole
        }

sees to it that the user gets saved.  The printout is the following:

The username: jackson
The password: password
The username: jackson
The password: password
The username: jackson
The password: password
The username: jackson
The password: password
The username: jackson
The password: $2a$10$VRakfS5Zp2LUyLqf3zNunuBdlnmrfjTshK1fVV8i3JcnfmdiFVxk.
The username: jackson
The password: $2a$10$VRakfS5Zp2LUyLqf3zNunuBdlnmrfjTshK1fVV8i3JcnfmdiFVxk.

That's how many times this method gets called with one save() and one show().

 

Trying to save(flush: true) 'this' if it has no id (transient) results in a loop.  Top (Linux command) shows it uses two cores of the CPU fully and one partially.  Memory usage for just this process is about 25% at the time.   

 

So, this is far from a solution, but a pointer indicating the cause of the problem.  I'm very sure everyone will run into this using Grails 3.1.2 and Spring Security Core.  Give it time.  Grails 3.1.2 has been out only days.  This has to be resolved.

 

Hopefully the solution is easy.  

 

Chris

 

On Friday, March 4, 2016 at 12:24:18 AM UTC+11, Chris Malan wrote:

On trying to save a user (called SecUser in the code) the following happens:

object references an unsaved transient instance - save the transient instance before flushing: security.SecUser. Stacktrace follows:

java.lang.reflect.InvocationTargetException: null

         at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.groovy:53) ~[spring-security-core-3.0.3.jar:na]

         at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.groovy:62) ~[spring-security-core-3.0.3.jar:na] etc. and

Caused by: org.springframework.beans.InvalidPropertyException: Invalid property 'authorities' of bean class [security.SecUser]: Getter for property 'authorities' threw exception; nested exception is java.lang.reflect.InvocationTargetException
        at grails.transaction.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:96) ~[grails-core-3.1.2.jar:3.1.2]

 

This is caused by the middle line of this method in the User domain class generated by s2-quickstart:

 Set<SecRole> getAuthorities() {
        SecUserSecRole.findAllBySecUser(this)*.secRole
}

 

Apparently the User is not persisted to the database at this stage.  The save is save(flush: true).

 

This method has been in the User domain class for some time and didn't create problems in earlier versions.  I thought maybe Hibernate is responsible and used Hibernate5 as well.  No change. 

 

It's a brand new project with only Spring Security Core added as a dependency and controllers and gsp pages generated.  If one tries to do it in Bootstrap.groovy the result is the same.

 

How can one get past this?

 

Thanks.

 

Chris

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/6fb73f64-d049-4a50-b393-1d3a3a922cb6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


If you reply to this email, your message will be added to the discussion below:

http://grails.1312388.n4.nabble.com/Grails-3-1-2-and-Spring-Security-Core-won-t-save-User-tp4660094p4660095.html

To start a new topic under Grails Dev Discuss, email [hidden email]
To unsubscribe from Grails, click here.
NAML

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Grails 3.1.2 and Spring Security Core won't save User

droggo
In reply to this post by Chris Malan

It’s a bug on 3.1.2. You can migrate to 3.1.3 or make this method `transient` or add `static transients = [‘authorities’]` to fix it.

See https://github.com/grails/grails-core/issues/9749 for details


W dniu piątek, 4 marca 2016 06:05:13 UTC+1 użytkownik Chris Malan napisał:
Some progress.  Changing getAuthorities to the following:

Set<SecRole> getAuthorities() {
if(!<a href="http://this.id" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\75http%3A%2F%2Fthis.id\46sa\75D\46sntz\0751\46usg\75AFQjCNFGLoPFD_d9JTTNqfqZ6geUV4-xjw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\75http%3A%2F%2Fthis.id\46sa\75D\46sntz\0751\46usg\75AFQjCNFGLoPFD_d9JTTNqfqZ6geUV4-xjw&#39;;return true;">this.id){
println "The username: ${this.username}"
println "The password: ${this.password}"
}
return [] as Set
//SecUserSecRole.findAllBySecUser(this)*.secRole
}
sees to it that the user gets saved.  The printout is the following:
The username: jackson
The password: password
The username: jackson
The password: password
The username: jackson
The password: password
The username: jackson
The password: password
The username: jackson
The password: $2a$10$VRakfS5Zp2LUyLqf3zNunuBdlnmrfjTshK1fVV8i3JcnfmdiFVxk.
The username: jackson
The password: $2a$10$VRakfS5Zp2LUyLqf3zNunuBdlnmrfjTshK1fVV8i3JcnfmdiFVxk.
That's how many times this method gets called with one save() and one show().

Trying to save(flush: true) 'this' if it has no id (transient) results in a loop.  Top (Linux command) shows it uses two cores of the CPU fully and one partially.  Memory usage for just this process is about 25% at the time.   

So, this is far from a solution, but a pointer indicating the cause of the problem.  I'm very sure everyone will run into this using Grails 3.1.2 and Spring Security Core.  Give it time.  Grails 3.1.2 has been out only days.  This has to be resolved.

Hopefully the solution is easy.  

Chris

On Friday, March 4, 2016 at 12:24:18 AM UTC+11, Chris Malan wrote:
On trying to save a user (called SecUser in the code) the following happens:
object references an unsaved transient instance - save the transient instance before flushing: security.SecUser. Stacktrace follows:
java.lang.reflect.InvocationTargetException: null
at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.groovy:53) ~[spring-security-core-3.0.3.jar:na]
at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.groovy:62) ~[spring-security-core-3.0.3.jar:na] etc. and
Caused by: org.springframework.beans.InvalidPropertyException: Invalid property 'authorities' of bean class [security.SecUser]: Getter for property 'authorities' threw exception; nested exception is java.lang.reflect.InvocationTargetException
at grails.transaction.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:96) ~[grails-core-3.1.2.jar:3.1.2]
 
This is caused by the middle line of this method in the User domain class generated by s2-quickstart:
 Set<SecRole> getAuthorities() {
SecUserSecRole.findAllBySecUser(this)*.secRole
}

Apparently the User is not persisted to the database at this stage.  The save is save(flush: true).

This method has been in the User domain class for some time and didn't create problems in earlier versions.  I thought maybe Hibernate is responsible and used Hibernate5 as well.  No change. 

It's a brand new project with only Spring Security Core added as a dependency and controllers and gsp pages generated.  If one tries to do it in Bootstrap.groovy the result is the same.

How can one get past this?

Thanks.

Chris

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/da2f67c5-efd9-41e8-8601-2e991fd8f123%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Grails 3.1.2 and Spring Security Core won't save User

Chris Malan
Changing getAuthorities() to the following also works:
Set<SecRole> getAuthorities() {
if(this.id){
return SecUserSecRole.findAllBySecUser(this)*.secRole
}
else{
return [] as Set
}
}

On Friday, March 4, 2016 at 5:07:51 PM UTC+11, [hidden email] wrote:

It’s a bug on 3.1.2. You can migrate to 3.1.3 or make this method `transient` or add `static transients = [‘authorities’]` to fix it.

See <a href="https://github.com/grails/grails-core/issues/9749" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fgrails%2Fgrails-core%2Fissues%2F9749\46sa\75D\46sntz\0751\46usg\75AFQjCNFSe4HS-7C0wbDgYij74b71MefHBw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fgrails%2Fgrails-core%2Fissues%2F9749\46sa\75D\46sntz\0751\46usg\75AFQjCNFSe4HS-7C0wbDgYij74b71MefHBw&#39;;return true;">https://github.com/grails/grails-core/issues/9749 for details


W dniu piątek, 4 marca 2016 06:05:13 UTC+1 użytkownik Chris Malan napisał:
Some progress.  Changing getAuthorities to the following:

Set<SecRole> getAuthorities() {
if(!<a href="http://this.id" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\75http%3A%2F%2Fthis.id\46sa\75D\46sntz\0751\46usg\75AFQjCNFGLoPFD_d9JTTNqfqZ6geUV4-xjw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\75http%3A%2F%2Fthis.id\46sa\75D\46sntz\0751\46usg\75AFQjCNFGLoPFD_d9JTTNqfqZ6geUV4-xjw&#39;;return true;">this.id){
println "The username: ${this.username}"
println "The password: ${this.password}"
}
return [] as Set
//SecUserSecRole.findAllBySecUser(this)*.secRole
}
sees to it that the user gets saved.  The printout is the following:
The username: jackson
The password: password
The username: jackson
The password: password
The username: jackson
The password: password
The username: jackson
The password: password
The username: jackson
The password: $2a$10$VRakfS5Zp2LUyLqf3zNunuBdlnmrfjTshK1fVV8i3JcnfmdiFVxk.
The username: jackson
The password: $2a$10$VRakfS5Zp2LUyLqf3zNunuBdlnmrfjTshK1fVV8i3JcnfmdiFVxk.
That's how many times this method gets called with one save() and one show().

Trying to save(flush: true) 'this' if it has no id (transient) results in a loop.  Top (Linux command) shows it uses two cores of the CPU fully and one partially.  Memory usage for just this process is about 25% at the time.   

So, this is far from a solution, but a pointer indicating the cause of the problem.  I'm very sure everyone will run into this using Grails 3.1.2 and Spring Security Core.  Give it time.  Grails 3.1.2 has been out only days.  This has to be resolved.

Hopefully the solution is easy.  

Chris

On Friday, March 4, 2016 at 12:24:18 AM UTC+11, Chris Malan wrote:
On trying to save a user (called SecUser in the code) the following happens:
object references an unsaved transient instance - save the transient instance before flushing: security.SecUser. Stacktrace follows:
java.lang.reflect.InvocationTargetException: null
at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.groovy:53) ~[spring-security-core-3.0.3.jar:na]
at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.groovy:62) ~[spring-security-core-3.0.3.jar:na] etc. and
Caused by: org.springframework.beans.InvalidPropertyException: Invalid property 'authorities' of bean class [security.SecUser]: Getter for property 'authorities' threw exception; nested exception is java.lang.reflect.InvocationTargetException
at grails.transaction.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:96) ~[grails-core-3.1.2.jar:3.1.2]
 
This is caused by the middle line of this method in the User domain class generated by s2-quickstart:
 Set<SecRole> getAuthorities() {
SecUserSecRole.findAllBySecUser(this)*.secRole
}

Apparently the User is not persisted to the database at this stage.  The save is save(flush: true).

This method has been in the User domain class for some time and didn't create problems in earlier versions.  I thought maybe Hibernate is responsible and used Hibernate5 as well.  No change. 

It's a brand new project with only Spring Security Core added as a dependency and controllers and gsp pages generated.  If one tries to do it in Bootstrap.groovy the result is the same.

How can one get past this?

Thanks.

Chris

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/0cd62e5e-d19a-4e58-8ca1-85b12974aab3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...