0 Replies Latest reply on Jul 14, 2009 12:35 PM by Ruben Jenster

    user creation @Startup through IdentityManager API

    Ruben Jenster Newbie


      since this is my first post in this forum: Hello to every seam-user out there!

      I've a problem with the IdentityManager API. I want to create a new user on application startup for development purposes using the IdentityManager API with the following component:

      public class DebugMethods {
           public void createTestUser(){
                System.out.println("creating test user");
                IdentityManager.instance().createUser("someuser", "somepass");

      Actually the call to createTestUser() fails because no session context is active

      Caused by: java.lang.IllegalStateException: No active session context

      When I put the component into session scope, then createTestUser() is called when a session is created. Unfortunately the user isn't created either. But this time no Exception is thrown.
      Rules for creating a user are correctly setup in security.drl:

      rule CanCreateTestUser
        c: PermissionCheck(target == "seam.user", action == "create")

      When I add a button for calling createTestUser() manually then the user is created.
      I stepped through the code, but actually I can't find the problem.

      Can someone please tell me why this doesn't work?
      How do you create a user for development purposes on application startup?