4 Replies Latest reply on Mar 10, 2007 10:32 PM by Michael Darr

    SeamSecurity

    Konstantin Kauz Novice

      What i do wrong?

      19:53:39,203 ERROR [SeamLoginModule] Error invoking login method
      javax.faces.el.EvaluationException: Exception while invoking expression #{authen ticator.authenticate}
      at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java :165)
      at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpressi on(ActionParamBindingHelper.java:59)
      at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionPara mMethodBinding.java:74)
      at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:102)
      at org.jboss.seam.security.jaas.SeamLoginModule.login(SeamLoginModule.ja va:102)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.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:1 86)
      at javax.security.auth.login.LoginContext$5.run(LoginContext.java:706)
      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:206)
      at org.jboss.seam.security.Identity.authenticate(Identity.java:199)
      at org.jboss.seam.security.Identity.login(Identity.java:184)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at com.sun.el.parser.AstValue.invoke(AstValue.java:151)
      at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
      at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.ja va:68)
      at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.ja va:69)
      at org.apache.myfaces.application.ActionListenerImpl.processAction(Actio nListenerImpl.java:63)
      at javax.faces.component.UICommand.broadcast(UICommand.java:106)
      Caused by: javax.faces.el.PropertyNotFoundException: Base is null: authenticator
      at org.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(Value BindingImpl.java:460)
      at org.apache.myfaces.el.MethodBindingImpl.resolveToBaseAndProperty(Meth odBindingImpl.java:180)
      at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java :114)
      at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpressi on(ActionParamBindingHelper.java:59)
      at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionPara mMethodBinding.java:74)
      at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:102)
      at org.jboss.seam.security.jaas.SeamLoginModule.login(SeamLoginModule.ja va:102)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.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:1 86)
      at javax.security.auth.login.LoginContext$5.run(LoginContext.java:706)
      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:206)
      at org.jboss.seam.security.Identity.authenticate(Identity.java:199)
      at org.jboss.seam.security.Identity.login(Identity.java:184)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at com.sun.el.parser.AstValue.invoke(AstValue.java:151)
      at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
      at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.ja va:68)
      at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.ja va:69)

        • 1. Re: SeamSecurity
          Konstantin Kauz Novice

           

          public boolean authenticate() {
          
          
           log.info("authenticating #0", identity.getUsername());
           try{
           Usr usr = (Usr) em.createQuery("from Usr where bname = :bname and passwort = :passwort")
           .setParameter("bname", Identity.instance().getUsername())
           .setParameter("passwort", Identity.instance().getPassword())
           .getSingleResult();
          
           if (usr.getRoles() != null) {
           identity.addRole( usr.getRoles());
           return true;
           }
           return false;
           } catch (NoResultException ex) {
           FacesMessages.instance().add("Benutzername/Passwort falsch!");
           return false;
           }
          
           }


          • 2. Re: SeamSecurity
            Gavin King Master

            There is no component called "autheticator". Are you sure you have an @Name annotation on the class?

            • 3. Re: SeamSecurity
              Konstantin Kauz Novice

              thanks, that was...

              It doesn't work with both options, i don't understand the difference

              between

              @PersistenceContext
              private EntityManager em;

              and


              @In EntityManager em;


              Code:

              try{
               Usr usr = (Usr) em.createQuery(
               "from Usr where bname = :username and passwort = :password")
               .setParameter("username", identity.getUsername())
               .setParameter("password", identity.getPassword())
               .getSingleResult();
              
               if (usr != null) {
              
               log.info("------------------hallo");
               }
              
               return false;
               } catch (NoResultException ex) {
               FacesMessages.instance().add("Benutzername/Passwort falsch!");
               return false;
               }



              Exeption with @In


              20:22:14,139 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 org.jboss.seam.core.Expressions$2.invoke(Expressions.java:102)
              at org.jboss.seam.security.jaas.SeamLoginModule.login(SeamLoginModule.java:102)
              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 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:206)
              at org.jboss.seam.security.Identity.authenticate(Identity.java:199)
              at org.jboss.seam.security.Identity.login(Identity.java:184)
              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:151)
              at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
              at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
              at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)
              at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
              at javax.faces.component.UICommand.broadcast(UICommand.java:106)
              Caused by: org.jboss.seam.RequiredException: In attribute requires value for component: authenticator.em
              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)
              at org.jboss.seam.interceptors.BijectionInterceptor.bijectNonreentrantComponent(BijectionInterceptor.java:76)
              at org.jboss.seam.interceptors.BijectionInterceptor.bijectComponent(BijectionInterceptor.java:58)
              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 org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
              at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
              at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationInterceptor.java:52)
              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 org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
              at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
              at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
              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 org.jboss.seam.util.Reflections.invoke(Reflections.java:18)


              why i do wrong?

              • 4. Re: SeamSecurity
                Michael Darr Newbie


                PersistenceContext is to be used in objects that are Session Beans.

                EntityManager is to be injected into JavaBeans that need security.

                Do you have something ike -->

                <component name="entityManager" auto-create="true" class="org.jboss.seam.core.ManagedPersistenceContext">
                java:/ticketingSystemEntityManagerFactory


                Defined in your components.xml