5 Replies Latest reply on Jul 28, 2010 8:07 AM by Tanya Ruttenberg

    Getting Seam component (Identity) in an entity listener

    Monkey Den Master

      Is it possible to get access to the Identity object from within an entity listener?  I'm trying to implement an audit trail for some entities but Identity is always null.  Seems like it would be pretty simple.  My entity bean is annotated with:

      @EntityListeners({JPAValidateListener.class, AuditableListener.class})

      And my AuditableListener

      public class AuditableListener {
          public void prePersist(Auditable auditable) {
              String username = "ADMIN_SYSTEM";
              Identity identity = (Identity)Component.getInstance("org.jboss.seam.security.identity");
              if (identity.getUsername() != null) {
                  username = identity.getUsername();