3 Replies Latest reply on Apr 27, 2010 12:00 PM by Kevin Sapper

    Seam bean not created in any context

    Sean Li Newbie

      This might be a very simple problem, but I've been stuck on this for a couple of days.

      I was trying the sample app which one registers to the web site and the user info's stored to DB. I chose to implement this using JPA entity bean and Stateless session bean.

      Here's my User entity annotations:

      @Table(name = "USER", uniqueConstraints = {
                @UniqueConstraint(columnNames = "username"),
                @UniqueConstraint(columnNames = "email_address") })
      public class User implements Serializable {
           @Column(name = "email_address", nullable = false)
           public String getEmailAddress() {
                return emailAddress;

      and here's my xhtml snippet:

              <f:facet name="header">Register</f:facet>
              <h:form id="registerActionForm" styleClass="edit">
                     <s:decorate id="nameField" template="layout/edit.xhtml">     
                          <ui:define name="label">Name</ui:define>
                          <h:inputText id="name" value="#{newUser.name}" required="true"/>
                     <s:decorate id="emailAddressField" template="layout/edit.xhtml">     
                          <ui:define name="label">Email Address</ui:define>
                          <h:inputText id="emailAddress" value="#{newUser.emailAddress}" required="true"/>
                     <div class="actionButtons">
                          <s:button id="registerAction" value="register" action="#{registerAction.register}"/>

      And here's my action bean:

      public class RegisterActionBean implements RegisterAction
          @Logger private Log log;
          @In StatusMessages statusMessages;
          public String register()
              // implement your business logic here
              log.info("registerAction.registerAction() action called");
              User newUser = (User)Contexts.lookupInStatefulContexts("newUser");
              if (newUser == null){
                   log.info("newUser not passed");
                   return null;
              log.info("register success");
              return "success";
          // add additional action methods

      I always got the message 'newUser not passed' which I don't know why.

      In my understanding:

      1) validation should occur before the action component is invoked. it doesn't happen in my case, as my hibernate validation for email never got called.
      2) the entity component should be created automatically, but I cannot find it from any scope context.

      There must be something missed. Please advise.