Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7849811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:38:53+00:00 2026-06-02T18:38:53+00:00

I’m integrating the SpringSecurity plugin with an application. To do so, I installed the

  • 0

I’m integrating the SpringSecurity plugin with an application. To do so, I installed the plugin and ran the s2-quickstart script, which created three domain classes: SecUser, SecRole, and SecUserSecRole as well as the login/logout controllers.

As I already have an existing User domain class and wanted to keep it, I modified User to extend SecUser and removed the overlapping fields of username and password from User. Also, I’ve added tablePerHierarchy false to both User and SecUser mapping sections.

In BootStrap, I’m trying to create an Admin user to exist on startup. To do so, I create a new SecRole object adminRole with the authority set to ROLE_ADMIN. Then, I create a new User object and check if it contains the admin role via

def springSecurityService
def init {
    def adminUser = User.findByUsername('admin') ?: new User(
        username:'admin',
        password:'adminUser',
        userType:'Admin',
        enabled:true    
    ).save(failOnError:true)

    if (!adminUser.authorities.contains(adminRole))
        SecUserSecRole.create adminUser, adminRole, true

}

My issue is I keep getting a transient instance exception, regardless if adminUser is declared to be a User or SecUser instance. As userType has a constraint of blank:false, if I comment out the userType field when creating a User instance, I get an excception stating that null is not a valid setting for userType. When I include it, I get the transient object exception: object references an unsaved transient instance – save the transient instance before flushing: books4africa.SecUser, so I know I’m passing all User validation settings.

What causes a valid User object to not be saved in this circumstance?

EDIT

The solution for this issue was to delete the existing dev database file and reinitialize the application. My guess is that there was some sort of conflict between the db and Spring Security with the original db, so restarting the app with a fresh db solved the problem.

Since none of the answers below solved the exact problem, I won’t be accepting in this instance, but thanks for the help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:38:57+00:00Added an answer on June 2, 2026 at 6:38 pm

    To me it seems like a problem with the domains or the way you’re creating instances of them.

    You said:

    I modified User to extend SecUser and removed the overlapping fields
    of username and password from User. Also, I’ve added tablePerHierarchy
    false to both User and SecUser mapping sections.

    But maybe you didn’t tell the plugin that you did that. Please, have a look a the documentation regarding the domain classes. To use your own domains you must configure the SpringSecurity plugin (the doc has all info you need). So, for example, if you want to use your own user class. you put something like this on your config:

    grails.plugins.springsecurity.userLookup.userDomainClassName = 'your.package.NameOfYourClass'
    

    And that will tell the plugin that the class it must use for users is NameOfYourClass.

    It is important you use the default classes, that the quickstart generated, as an example, is the easiest way of properly using custom Users and Roles classes (just copy every property to your own classes, and rename as you see fit).

    And take also a look at the tutorials, to see how to properly save users and roles.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.