1 Reply Latest reply on Jun 16, 2008 9:04 AM by Joshua Jackson

    NameNotFoundException: LoginAction not bound

    JR Wilbert Newbie

      Can anyone help shed some light on what I am doing wrong with setting up authentication via the database.


      I can't access EntityManger at all from the LoginAction class


      This is based off of the booking example but built on the Jboss Developer Studio



      This bombs with the follow error


      Any help is appreciated


      Thanks


      19:03:10,493 ERROR [SeamLoginModule] Error invoking login method
      org.jboss.seam.InstantiationException: Could not instantiate Seam component: login
              at org.jboss.seam.Component.newInstance(Component.java:1740)
              at org.jboss.seam.Component.getInstance(Component.java:1643)
              at org.jboss.seam.Component.getInstance(Component.java:1610)
              at org.jboss.seam.jsf.SeamVariableResolver.resolveVariable(SeamVariableResolver.java:53)
              at com.sun.faces.el.VariableResolverChainWrapper.getValue(VariableResolverChainWrapper.java:107)
              at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
              at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
              at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:45)
              at org.apache.el.parser.AstValue.getTarget(AstValue.java:42)
              at org.apache.el.parser.AstValue.invoke(AstValue.java:127)
              at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
              at com.sun.faces.application.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
              at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:58)
              at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:75)
              at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:148)
              at org.jboss.seam.security.jaas.SeamLoginModule.login(SeamLoginModule.java:104)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
              at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
              at javax.security.auth.login.LoginContext$5.run(LoginContext.java:706)
              at java.security.AccessController.doPrivileged(Native Method)
              at javax.security.auth.login.LoginContext.invokeCreatorPriv(LoginContext.java:703)
              at javax.security.auth.login.LoginContext.login(LoginContext.java:575)
              at org.jboss.seam.security.Identity.authenticate(Identity.java:247)
              at org.jboss.seam.security.Identity.authenticate(Identity.java:240)
              at org.jboss.seam.security.Identity.login(Identity.java:170)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at com.sun.el.parser.AstValue.invoke(AstValue.java:174)
              at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:286)
              at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
              at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
              at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
              at javax.faces.component.UICommand.broadcast(UICommand.java:387)
              at org.ajax4jsf.framework.ajax.AjaxViewRoot.processEvents(AjaxViewRoot.java:180)
              at org.ajax4jsf.framework.ajax.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:158)
              at org.ajax4jsf.framework.ajax.AjaxViewRoot.processApplication(AjaxViewRoot.java:346)
              at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
              at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
              at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
              at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:60)
              at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
              at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
              at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
              at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
              at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
              at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
              at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
              at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
              at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
              at java.lang.Thread.run(Thread.java:595)
      Caused by: javax.naming.NameNotFoundException: LoginAction not bound
              at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
              at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
              at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
              at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
              at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
              at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
              at javax.naming.InitialContext.lookup(InitialContext.java:351)
              at org.jboss.seam.Component.instantiateSessionBean(Component.java:1107)
              at org.jboss.seam.Component.instantiate(Component.java:1093)
              at org.jboss.seam.Component.newInstance(Component.java:1736)
              ... 80 more




      here is my components.xml


      <?xml version="1.0" encoding="UTF-8"?>
      <components xmlns="http://jboss.com/products/seam/components"
       xmlns:core="http://jboss.com/products/seam/core"
       xmlns:drools="http://jboss.com/products/seam/drools"
       xmlns:mail="http://jboss.com/products/seam/mail"
       xmlns:security="http://jboss.com/products/seam/security"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jboss.com/products/seam/core http://jboss.com/products/seam/core-1.1.xsd                   http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-1.1.xsd                  http://jboss.com/products/seam/security http://jboss.com/products/seam/security-1.1.xsd                  http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-1.2.xsd                  http://jboss.com/products/seam/components http://jboss.com/products/seam/components-1.1.xsd">
       <core:init debug="true" jndi-pattern="@jndiPattern@"/>
       <core:manager concurrent-request-timeout="500"
        conversation-id-parameter="cid"
        conversation-is-long-running-parameter="clr" conversation-timeout="120000"/>
       <core:managed-persistence-context auto-create="true"
        entity-manager-factory="#{PrismOnePortalEntityManagerFactory}" name="entityManager"/>
       <core:entity-manager-factory name="PrismOnePortalEntityManagerFactory" persistence-unit-name="PrismOnePortal"/>
       <core:ejb installed="@embeddedEjb@"/>
       <drools:rule-base name="securityRules">
        <drools:rule-files>
         <value>/security.drl</value>
        </drools:rule-files>
       </drools:rule-base>
       <security:identity authenticate-method="#{login.login}"
        remember-me="true" security-rules="#{securityRules}"/>
       <event type="org.jboss.seam.notLoggedIn">
        <action expression="#{redirect.captureCurrentView}"/>
       </event>
       <event type="org.jboss.seam.postAuthenticate">
        <action expression="#{redirect.returnToCapturedView}"/>
       </event>
       <mail:mail-session host="localhost" password="test" port="2525" username="test"/>
       <!-- For use with jBPM pageflow or process management 
        
         <core:jbpm>
            <core:process-definitions></core:process-definitions>
            <core:pageflow-definitions></core:pageflow-definitions>
         </core:jbpm>
         -->
      </components>
      




      Login.java


      import javax.ejb.Local;
      
      @Local
      public interface Login
      {
         public boolean login();
      }



      LoginAction.java


      import java.util.List;
      
      import javax.ejb.Stateless;
      import javax.faces.application.FacesMessage;
      import javax.faces.context.FacesContext;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;
      
      import org.jboss.seam.security.Identity;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Out;
      import org.jboss.seam.contexts.Context;
      
      
      @Stateless
      @Name("login")
      public class LoginAction implements Login
      {
         
         @In
         Identity identity;
      
         @Out
         private User user;
         
         @PersistenceContext
         private EntityManager em;
         
      
         public boolean login()
         {
            List<User> results = em.createQuery("select u from User u where username=:username and password=:password")
                  .setParameter("username", identity.getUsername())
                  .setParameter("password", identity.getPassword())
                  .getResultList();
            
            if ( results.size()==0 )
            {
              
               return false;
            }
            else
            {
               user = results.get(0);
               identity.addRole("visitor");
               return true;
            }
            
         }
      
      }