1 Reply Latest reply on Dec 15, 2008 5:44 AM by Wayne Hannam

    IdentityManager and SeamResourceServlet

    Wayne Hannam Newbie

      I have coded up an AbstractResource to be served up by the SeamResourceServlet, to enable my users when the navigate to a  URL in an email that is dispatched after they register.

      In this resource, I attempt to use IdentityManager.enableUser(username), and IdentityManager.grantRole(username,user).

      To obtain the reference to the IdentityManager from within the resource, I used IdentityManager.instance(), and a call to IdentityManager.listUser(), seems to verify, that it has the right store.

      However, when I make the calls to enableUser, and grantRole, no exception or error is thrown, and nothing in the database tables changes, the enabled field of the account is still false, and no record is added to map the user role to the user.

      Here is the block of code that attempts this transaction:

      final IdentityManager identityManager = IdentityManager.instance();
          new RunAsOperation() {
           public void execute() {
                try {
                     List<String> users = identityManager.listUsers();
                              // These were inserted for debugging purposes, and all return the values I expected
                     for(String user : users) { log.info("USER: " + user); }     
                     log.info("ENABLING USER: " + userAccount.getUsername());
                     log.info("USER EXISTS: " + userAccount.getUsername());
                     log.info("ROLE EXISTS: " + identityManager.roleExists("user"));
                } catch(Exception e) {
                     statusMessages.add(Severity.ERROR,"Unable to register user at this time, please try again later.");     

      Is there some other way I should be doing this ?

      Thank all for any help they may be able to provide.


        • 1. Re: IdentityManager and SeamResourceServlet
          Wayne Hannam Newbie

          I negleted to mention in the first post, that I am using JBoss 5.0.0.GA, and Seam-2.1.1.CR2

          The plot thickens on this one...........

          I also cannot persist changes to an entity via an EntityManager.

          The EntityManager is retrieved via:

          EntityManager = (EntityManager)Component.getInstance("entityManager");

          and I successfully retrieve the correct entity via:

          UserAccount userAccount = (UserAccount)entityManager.find(UserAccount.class,uid);

          Then, I update the enabled field of the UserAccount entity, and persist via:


          No Exceptions/Errors, database is NOT modified.

          I am not finding a whole lot in the way of examples, using the AbstractResource to take the place of a servlet and it's getting quite frustrating.

          Can anybody could point me to some working code, or point out the error of my ways ?