9 Replies Latest reply on Aug 31, 2009 8:16 PM by Kmali Malik

    authenticator

    Kmali Malik Newbie

      Hi,


      I have problems with the authenticor mechanism I have integrated to my application.
      I have simply taken the classes and methods from the booking example in seam 1.2.


      When I klick the register button in my application, the seam debug page comes up:


      Exception during request processing: javax.servlet.ServletException: Error calling action method of component with id id14:id19



      javax.faces.webapp.FacesServlet.service(FacesServlet.java:152)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
      org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
      org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
      org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:60)
      org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
      org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
      org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
      org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
      org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      java.lang.Thread.run(Thread.java:619)



      As I said, my code is inspired by the booking example...
      Do you have a idea how to fix this?


      Thanks

        • 1. Re: authenticator
          Arbi Sookazian Master

          show relevant code

          • 2. Re: authenticator
            Kmali Malik Newbie



            Hi,


            I don't really need the register function in my application. I just want the authenticator funktionality.


            But it doesn't work... This is what the jboss console displays:



            19:05:59,075 INFO  [Lifecycle] starting up: org.jboss.seam.security.identity
            19:05:59,091 WARN  [RuleBasedIdentity] no security rule base available - please install a RuleBase with the name 'securityRules' if permission checks are required.
            19:05:59,247 ERROR [STDERR] 30.08.2009 19:05:59 com.sun.facelets.compiler.TagLibraryConfig loadImplicit
            INFO: Added Library from: jar:file:/F:/JavaDev/jboss-4.0.5.GA/server/default/./tmp/deploy/tmp6376148280554565695FoFi.ear-contents/FoFi-exp.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jsf-html.taglib.xml
            19:05:59,247 ERROR [STDERR] 30.08.2009 19:05:59 com.sun.facelets.compiler.TagLibraryConfig loadImplicit
            INFO: Added Library from: jar:file:/F:/JavaDev/jboss-4.0.5.GA/server/default/./tmp/deploy/tmp6376148280554565695FoFi.ear-contents/FoFi-exp.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jstl-fn.taglib.xml
            19:05:59,262 ERROR [STDERR] 30.08.2009 19:05:59 com.sun.facelets.compiler.TagLibraryConfig loadImplicit
            INFO: Added Library from: jar:file:/F:/JavaDev/jboss-4.0.5.GA/server/default/./tmp/deploy/tmp6376148280554565695FoFi.ear-contents/FoFi-exp.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jstl-core.taglib.xml
            19:05:59,278 ERROR [STDERR] 30.08.2009 19:05:59 com.sun.facelets.compiler.TagLibraryConfig loadImplicit
            INFO: Added Library from: jar:file:/F:/JavaDev/jboss-4.0.5.GA/server/default/./tmp/deploy/tmp6376148280554565695FoFi.ear-contents/FoFi-exp.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jsf-core.taglib.xml
            19:05:59,294 ERROR [STDERR] 30.08.2009 19:05:59 com.sun.facelets.compiler.TagLibraryConfig loadImplicit
            INFO: Added Library from: jar:file:/F:/JavaDev/jboss-4.0.5.GA/server/default/./tmp/deploy/tmp6376148280554565695FoFi.ear-contents/FoFi-exp.war/WEB-INF/lib/jboss-seam-pdf.jar!/META-INF/seam-pdf.taglib.xml
            19:05:59,294 ERROR [STDERR] 30.08.2009 19:05:59 com.sun.facelets.compiler.TagLibraryConfig loadImplicit
            INFO: Added Library from: jar:file:/F:/JavaDev/jboss-4.0.5.GA/server/default/./tmp/deploy/tmp6376148280554565695FoFi.ear-contents/FoFi-exp.war/WEB-INF/lib/jboss-seam-ui.jar!/META-INF/seam-ui.taglib.xml
            19:05:59,294 ERROR [STDERR] 30.08.2009 19:05:59 com.sun.facelets.compiler.TagLibraryConfig loadImplicit
            INFO: Added Library from: jar:file:/F:/JavaDev/jboss-4.0.5.GA/server/default/./tmp/deploy/tmp6376148280554565695FoFi.ear-contents/FoFi-exp.war/WEB-INF/lib/jboss-seam-mail.jar!/META-INF/seam-mail.taglib.xml
            19:05:59,309 ERROR [STDERR] 30.08.2009 19:05:59 com.sun.facelets.compiler.TagLibraryConfig loadImplicit
            INFO: Added Library from: jar:file:/F:/JavaDev/jboss-4.0.5.GA/server/default/./tmp/deploy/tmp6376148280554565695FoFi.ear-contents/FoFi-exp.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jsf-ui.taglib.xml
            19:05:59,418 INFO  [MyfacesConfig] No context init parameter 'org.apache.myfaces.PRETTY_HTML' found, using default value true
            19:05:59,418 INFO  [MyfacesConfig] No context init parameter 'org.apache.myfaces.ALLOW_JAVASCRIPT' found, using default value true
            19:05:59,418 INFO  [MyfacesConfig] Tomahawk jar not available. Autoscrolling, DetectJavascript, AddResourceClass and CheckExtensionsFilter are disabled now.
            
            
            19:06:01,712 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:165)
                    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:597)
                    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:597)
                    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 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)
                    at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:94)
                    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:168)
                    at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:343)
                    at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
                    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                    at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
                    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.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.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:202)
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                    at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                    at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
                    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
                    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
                    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
                    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
                    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
                    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
                    at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
                    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
                    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
                    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
                    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
                    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
                    at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
                    at java.lang.Thread.run(Thread.java:619)
            Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: authenticator
                    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 org.apache.myfaces.config.LastVariableResolverInChain.resolveVariable(LastVariableResolverInChain.java:42)
                    at org.apache.myfaces.el.ValueBindingImpl$ELVariableResolver.resolveVariable(ValueBindingImpl.java:574)
                    at org.apache.commons.el.NamedValue.evaluate(NamedValue.java:124)
                    at org.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(ValueBindingImpl.java:455)
                    at org.apache.myfaces.el.MethodBindingImpl.resolveToBaseAndProperty(MethodBindingImpl.java:180)
                    at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:114)
                    ... 70 more
            Caused by: javax.naming.NameNotFoundException: AuthenticatorAction 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.server.NamingServer.lookup(NamingServer.java:270)
                    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
                    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
                    at javax.naming.InitialContext.lookup(InitialContext.java:392)
                    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) 




            I don't see anything that could cause this. My code is similar to the auhtenticator from the booking example.
            Do you have an idea?





            • 3. Re: authenticator
              Francisco Jose Peredo Noguez Master

              Kmali Malik wrote on Aug 29, 2009 23:59:


              Hi,

              I have problems with the authenticor mechanism I have integrated to my application.
              I have simply taken the classes and methods from the booking example in seam 1.2.



              Why are you using such a really really old version of Seam?


              • 4. Re: authenticator
                Francisco Jose Peredo Noguez Master

                Kmali Malik wrote on Aug 30, 2009 20:41:



                I don't see anything that could cause this. My code is similar to the auhtenticator from the booking example.
                Do you have an idea?




                Please post the code of your authenticator class (btw you wrote authenticator wrong: aUHtenticator , if you also wrote it wrong in your file, that could be causing this problem)

                • 5. Re: authenticator
                  Kmali Malik Newbie

                  The application was made in seam 1.2 a long time ago, I just want to implent the authenticator.
                  Do you recommend me to update Seam?


                  Here is my Code:


                  import javax.ejb.Local;
                  
                  @Local
                  public interface Authenticator
                  {
                     boolean authenticate();
                  }




                  import static org.jboss.seam.ScopeType.SESSION;
                  
                  
                  
                  import java.util.List;
                  
                  import javax.ejb.Stateless;
                  import javax.persistence.EntityManager;
                  import javax.persistence.PersistenceContext;
                  
                  import org.jboss.seam.annotations.Name;
                  import org.jboss.seam.annotations.Out;
                  
                  @Stateless
                  @Name("authenticator")
                  public class AuthenticatorAction implements Authenticator
                  {
                     @PersistenceContext EntityManager em;
                     
                     @Out(required=false, scope = SESSION)
                     private User user;
                     
                     public boolean authenticate()
                     {
                        List results = em.createQuery("select u from User u where u.username=#{identity.username} and u.password=#{identity.password}")
                              .getResultList();
                        
                        if ( results.size()==0 )
                        {
                           return false;
                        }
                        else
                        {
                           user = (User) results.get(0);
                           return true;
                        }
                     }
                  
                  }



                  In the components.xml I have inserted:


                  <security:identity authenticate-method="#{authenticator.authenticate}"/>





                  xxxxx-ds.xml:


                  <datasources>
                       <local-tx-datasource>
                          <jndi-name>bookingDatasource</jndi-name>
                          <connection-url>jdbc:hsqldb:.</connection-url>
                          <driver-class>org.hsqldb.jdbcDriver</driver-class>
                          <user-name>sa</user-name>
                          <password></password>
                      </local-tx-datasource>
                  </datasources>



                  But what I don't undestand is, how the booking example Application creates the database tables?
                  There is a import.sql file in booking with insert statements. Does Seam create the tables based on the import.sql?
                  When I connect to the hsql Database in den Joboss AS, I can't see any Databases...








                  • 6. Re: authenticator
                    Kmali Malik Newbie


                    As far as I understand, the authenticator.authenticate method can't be initiated:


                    19:06:01,712 ERROR [SeamLoginModule] Error invoking login method
                    javax.faces.el.EvaluationException: Exception while invoking expression #{authenticator.authenticate}




                    This method should be initiated by {identity.login}


                    Additionally I get this warning:


                    15:41:51,596 WARN  [RuleBasedIdentity] no security rule base available - please
                    install a RuleBase with the name 'securityRules' if permission checks are requir
                    ed.



                    So maybe something is missing in any of the comfiguration files?


                    • 7. Re: authenticator
                      Kmali Malik Newbie


                      During the deployment I get this error:


                      --- MBeans waiting for other MBeans ---
                      ObjectName: jboss.j2ee:service=EJB3,module=FoFi.jar
                        State: FAILED
                        Reason: java.lang.RuntimeException: Illegal @PersistenceUnit on javax.persiste
                      nce.EntityManager de.atune.fofi.application.AuthenticatorAction.em :There is no
                      default persistence unit in this deployment.
                      
                      --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
                      ObjectName: jboss.j2ee:service=EJB3,module=FoFi.jar
                        State: FAILED
                        Reason: java.lang.RuntimeException: Illegal @PersistenceUnit on javax.persiste
                      nce.EntityManager de.atune.fofi.application.AuthenticatorAction.em :There is no
                      default persistence unit in this deployment.



                      • 8. Re: authenticator
                        Francisco Jose Peredo Noguez Master

                        Please try changing the name of the em variable to entityManager

                        • 9. Re: authenticator
                          Kmali Malik Newbie

                          Francisco Peredo wrote on Aug 31, 2009 17:08:


                          Please try changing the name of the em variable to entityManager


                          I have tried it, but I get the same exeption. If I remove @PersistenceContext EntityManager em the exeption disapeers
                          and I'm able to log in with this bypass code:




                          import static org.jboss.seam.ScopeType.SESSION;
                          
                          import java.util.List;
                          
                          import javax.ejb.Stateless;
                          import javax.persistence.EntityManager;
                          import javax.persistence.PersistenceContext;
                          
                          import org.jboss.seam.annotations.In;
                          import org.jboss.seam.annotations.Name;
                          import org.jboss.seam.annotations.Out;
                          import org.jboss.seam.security.Identity;
                          
                          @Stateless
                          @Name("authenticator")
                          public class AuthenticatorAction implements Authenticator
                          {
                             //@PersistenceContext EntityManager em;
                                
                             @Out(required=false, scope = SESSION)
                             private User user;
                             @In
                             Identity identity;
                             
                             public boolean authenticate()
                             {
                                 if (identity.getUsername() == "test")
                                 {
                                         return true;
                                 }
                                 else
                                 {
                                      return true;
                                 }
                                    
                             }
                          }



                          So what is worng with the @PersistenceContext annotation? It works with the booking example application...