I’m trying to add a reference from the default Spring Security user domain class to another class which should hold additional user info.
class User {
transient springSecurityService
String username
String password
boolean enabled
boolean accountExpired
boolean accountLocked
boolean passwordExpired
Profile profile
...
…and…
class Profile {
static constraints = {
}
static belongsTo = [user : User]
String firstName
String lastName
}
From what I read this should be the way it works, but I get the following error :
ERROR context.GrailsContextLoader - Error executing bootstraps: null
Message: null
Line | Method
->> 32 | create in com.app.UserRole
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 15 | doCall in BootStrap$_closure1
| 301 | evaluateEnvironmentSpecificBlock in grails.util.Environment
| 294 | executeForEnvironment in ''
| 270 | executeForCurrentEnvironment . . in ''
| 303 | innerRun in java.util.concurrent.FutureTask$Sync
| 138 | run . . . . . . . . . . . . . . in java.util.concurrent.FutureTask
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 908 | run . . . . . . . . . . . . . . in ''
^ 662 | run in java.lang.Thread
Any idea?
We need to see your
BootStrapto be sure, but I suspect it’s because you’re doing something likeand your new
Useris failing validation (which causessaveto returnnull).If you use
save(failOnError:true)you should get a different exception with a better indication of what the real problem is. Check that you have the rightconstraintsin yourUserclass, in particular note that GORM properties are by default non-nullable so if you want to be able to save aUserthat doesn’t have aProfileyou will need to add a constraint ofprofile(nullable:true).