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

    user creation @Startup through IdentityManager API

    rjenster

      Hi,


      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:


      @Name("devStartupMethods")
      @Scope(ScopeType.APPLICATION)
      @Startup
      public class DebugMethods {
           
           @Create
           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
      when
        c: PermissionCheck(target == "seam.user", action == "create")
      then
        c.grant();
      end



      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?


      Regards,
      Ruben