5 Replies Latest reply on Feb 23, 2007 5:50 PM by Richard Teviotdale

    SeamLoginModule EntityManager injection difficulties

    Richard Teviotdale Newbie

      I am running Seam version 1.1.6 on a JBoss 4.0.5.GA server.

      While following the example from the Seam documentation (page 124) for creating a SeamLoginModule authentication method I have run into the following error:

      09:37:41,228 ERROR [SeamLoginModule] Error invoking login method
      javax.faces.el.EvaluationException: Exception while invoking expression #{authenticator.authenticate}
       at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:153)
       at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:59)
       at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:74)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: org.jboss.seam.RequiredException: In attribute requires value for component: authenticator.entityManager
       at org.jboss.seam.Component.getInstanceToInject(Component.java:1920)
       at org.jboss.seam.Component.injectFields(Component.java:1386)
       at org.jboss.seam.Component.inject(Component.java:1156)
       ... 59 more

      This suggests that Seam is unable to locate and inject the entityManager by its component name. The relevant java bean that the login component is calling is as follows:

      public class Authenticator
       @In EntityManager entityManager;
       public boolean authenticate()
       return true;

      For completeness here, is the form that is calling the validation:
      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
      <ui:define name="body">
       <p>Please login using any username and password</p>
       <h:messages styleClass="message"/>
       <div class="dialog">
       <div class="prop">
       <span class="name">Username</span>
       <span class="value">
       <h:inputText id="username" value="#{identity.username}"/>
       <div class="prop">
       <span class="name">Password</span>
       <span class="value">
       <h:inputSecret id="password" value="#{identity.password}"/>
       <div class="prop">
       <span class="name">Remember me</span>
       <span class="value">
       <h:selectBooleanCheckbox id="rememberMe" value="#{identity.rememberMe}"/>
       <div class="actionButtons">
       <h:commandButton value="Login" action="#{identity.login}"/>

      I have also tried to annotate the EntityManager object in the following ways:
      @In("entityManager") EntityManager entityManager;
      @In(value="entityManager") EntityManager entityManager;

      but have recieved the same error.

      My configuration was generated by seam-gen and the authenticate method works fine until I try to inject an EntityManager into the component.

      I will create a Stateful Session Bean in order to try to inject the EntityManager by the EJB3.0 annotation @PersistenceContext rather than Seam @In annotation.

      Could this be caused by a filter loading order? I've looked at web.xml and it does not seem to be the cause. I think too that the identity component is a Seam component (ie. eats its own dogfood), therefore should not be a problem, Maybe the identity component is instantiated before other components like the entity manager?

      P.S. Thank you Gavin King for all your past helpful answers.