1 2 Previous Next 15 Replies Latest reply on Nov 30, 2009 1:55 PM by guy bashan

    Token-based Remember-me is not working

    Johnny Ren Newbie

      Tested environmental: JBOSS 4.2.3, Seam 2.1.0.SP1, Seam 2.1.2,

      Tested application: examples/jpa

      Steps to reproduce the problem:

      Step1: create an AuthenticationToken class as described in 15.3.5.1.

      Stpe2: Modify the components.xml as described in 15.3.5.1.

       
           <security:jpa-token-stor token-class="org.jboss.seam.example.jpa.AuthenticationToken"/>
          <security:remember-me mode="autoLogin"/>
         <event type="org.jboss.seam.security.notLoggedIn">
              <action execute="#{redirect.captureCurrentView}"/>
              <action execute="#{identity.tryLogin()}"/>
          </event>
          <event type="org.jboss.seam.security.loginSuccessful">
              <action execute="#{redirect.returnToCapturedView}"/>
          </event>

      Step 3: Modify the home.xhtml under examples\jpa\view as described in 15.3.5


                     <div>
                           <h:outputLabel for="rememberMe" value="Remember me"/>
          <h:selectBooleanCheckbox id="rememberMe" value="#{rememberMe.enabled}"/>
        </div>
      Step 4: execute ant jboss
      Step 5: deploy the jboss-seam-jpa.war

      Step 6:  go to http://localhost:8080/jboss-seam-jpa/home.seam

      Step 7: Select Remember me and use “demo/demo” to login.

      Result:

      javax.servlet.ServletException: #{identity.login}: org.jboss.seam.security.management.IdentityManagementException: Could not create account



      package org.jboss.seam.example.jpa;

      import java.io.Serializable;
      import javax.persistence.Entity;
      import javax.persistence.GeneratedValue;
      import javax.persistence.Id;

      import org.jboss.seam.annotations.security.TokenUsername;
      import org.jboss.seam.annotations.security.TokenValue;

      /**
      *
      */

      @Entity
      public class AuthenticationToken implements Serializable { 
         private Integer tokenId;
         private String username;
         private String value;
        
         @Id @GeneratedValue
         public Integer getTokenId() {
            return tokenId;
         }
        
         public void setTokenId(Integer tokenId) {
            this.tokenId = tokenId;
         }
        
         @TokenUsername
         public String getUsername() {
            return username;
         }
        
         public void setUsername(String username) {
            this.username = username;
         }
        
         @TokenValue
         public String getValue() {
            return value;
         }
        
         public void setValue(String value) {
            this.value = value;
         }
      }



        • 1. Re: Token-based Remember-me is not working
          Jean Luc Apprentice

          post the stack trace, not just the exception.

          • 2. Re: Token-based Remember-me is not working
            Johnny Ren Newbie
            Hi Jean,

            thanks for your effort.

            Johnny



            javax.servlet.ServletException: #{identity.login}: org.jboss.seam.security.management.IdentityManagementException: Could not create account
                 javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                 org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
                 org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                 org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
                 org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
                 org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                 org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


            root cause

            javax.faces.FacesException: #{identity.login}: org.jboss.seam.security.management.IdentityManagementException: Could not create account
                 com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
                 javax.faces.component.UICommand.broadcast(UICommand.java:387)
                 org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
                 org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
                 org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
                 org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
                 com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
                 com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
                 com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
                 javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                 org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
                 org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                 org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
                 org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
                 org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                 org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


            root cause

            javax.faces.el.EvaluationException: org.jboss.seam.security.management.IdentityManagementException: Could not create account
                 javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
                 com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
                 javax.faces.component.UICommand.broadcast(UICommand.java:387)
                 org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
                 org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
                 org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
                 org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
                 com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
                 com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
                 com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
                 javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                 org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
                 org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                 org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
                 org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
                 org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                 org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


            root cause

            org.jboss.seam.security.management.IdentityManagementException: Could not create account
                 org.jboss.seam.security.JpaTokenStore.createToken(JpaTokenStore.java:90)
                 org.jboss.seam.security.RememberMe.postAuthenticate(RememberMe.java:385)
                 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 java.lang.reflect.Method.invoke(Method.java:597)
                 org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
                 org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
                 org.jboss.seam.Component.callComponentMethod(Component.java:2253)
                 org.jboss.seam.core.Events.raiseEvent(Events.java:85)
                 org.jboss.seam.security.Identity.postAuthenticate(Identity.java:397)
                 org.jboss.seam.security.Identity.authenticate(Identity.java:345)
                 org.jboss.seam.security.Identity.authenticate(Identity.java:332)
                 org.jboss.seam.security.Identity.login(Identity.java:259)
                 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 java.lang.reflect.Method.invoke(Method.java:597)
                 org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:335)
                 org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:348)
                 org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
                 org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
                 org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
                 com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
                 javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
                 com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
                 javax.faces.component.UICommand.broadcast(UICommand.java:387)
                 org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
                 org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
                 org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
                 org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
                 com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
                 com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
                 com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
                 javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                 org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
                 org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                 org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
                 org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
                 org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                 org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


            root cause

            java.lang.NullPointerException
                 org.jboss.seam.security.JpaTokenStore.createToken(JpaTokenStore.java:80)
                 org.jboss.seam.security.RememberMe.postAuthenticate(RememberMe.java:385)
                 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 java.lang.reflect.Method.invoke(Method.java:597)
                 org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
                 org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
                 org.jboss.seam.Component.callComponentMethod(Component.java:2253)
                 org.jboss.seam.core.Events.raiseEvent(Events.java:85)
                 org.jboss.seam.security.Identity.postAuthenticate(Identity.java:397)
                 org.jboss.seam.security.Identity.authenticate(Identity.java:345)
                 org.jboss.seam.security.Identity.authenticate(Identity.java:332)
                 org.jboss.seam.security.Identity.login(Identity.java:259)
                 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 java.lang.reflect.Method.invoke(Method.java:597)
                 org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:335)
                 org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:348)
                 org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
                 org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
                 org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
                 com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
                 javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
                 com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
                 javax.faces.component.UICommand.broadcast(UICommand.java:387)
                 org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
                 org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
                 org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
                 org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
                 com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
                 com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
                 com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
                 javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                 org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
                 org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                 org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
                 org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
                 org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
                 org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                 org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

            • 3. Re: Token-based Remember-me is not working
              Jean Luc Apprentice

              It looks like the entity manager used by the JpaIdentityStore is null. Put a breakpoint at the root cause and confirm. If so, check your components.xml and how (and if!) the entity manager was declared. <persistence:managed-persistence-context ...>

              • 4. Re: Token-based Remember-me is not working
                Johnny Ren Newbie

                Hi Jean,


                I appreciate your help. I am talking about the JPA example from Seam release. The problem is that RememberMe is not even working for the JPA sample application. 


                I have debug the code. The entity manager is not null. However, I am not able to figure out the exact problem.I am not familar with Seam internal code. 


                It should not take more than 10 minutes to reproduce the problem.


                thanks again for your effort.


                Johnny




                 

                • 5. Re: Token-based Remember-me is not working
                  Johnny Ren Newbie
                  Hi Jean,

                  I found the problem. Thanks a lot for your help.

                  The problem is that RememberMe expect an EntityManager named "entityManager".  Seam Release JPA example use "em" for EntityManager.

                  Here is part of the components.xml from jpa example


                  <    <core:manager conversation-timeout="120000"
                                    concurrent-request-timeout="500"
                                    conversation-id-parameter="cid"/>
                                   
                      <transaction:entity-transaction entity-manager="#{em}"/>
                                   
                      <persistence:entity-manager-factory name="bookingDatabase" installed="@loadPersistenceUnits@"/>

                    
                  • 6. Re: Token-based Remember-me is not working
                    Jean Luc Apprentice

                    Great to hear you found it; I was not familiar with the JPA example. But this type of problem (a reliance of a particular component name) will surely occur again so thanks for sharing the solution.

                    • 7. Re: Token-based Remember-me is not working
                      guy bashan Apprentice

                      Hi johnny,
                      I am having the same exception.
                      I am using Hibernate.
                      I didn't understand what you changed to make it work. Can you please explain?


                      Thanks,
                      Guy.

                      • 8. Re: Token-based Remember-me is not working
                        Johnny Ren Newbie
                        I changed components.xml, created a Role class, modified User class and action classes.



                          <core:manager conversation-timeout="120000"
                                          concurrent-request-timeout="500"
                                          conversation-id-parameter="cid"/>
                                         
                            <transaction:entity-transaction entity-manager="#{entityManager}"/>
                                         
                            <persistence:entity-manager-factory name="bookingDatabase"/>
                           
                            <persistence:managed-persistence-context name="entityManager"
                                                       auto-create="true"
                                            entity-manager-factory="#{bookingDatabase}"/>
                                           
                           <security:identity authenticate-method="#{authenticator.authenticate}"/>
                           
                             <security:jpa-identity-store
                               user-class="org.jboss.seam.example.jpa.User"
                               role-class="org.jboss.seam.example.jpa.Role"
                               />
                           
                              <security:jpa-token-store
                           token-class="org.jboss.seam.example.jpa.AuthenticationToken"/>
                            <security:remember-me mode="autoLogin"/>
                           <event type="org.jboss.seam.security.notLoggedIn">
                                <action execute="#{redirect.captureCurrentView}"/>
                                <action execute="#{identity.tryLogin()}"/>
                              
                            </event>
                            <event type="org.jboss.seam.security.loginSuccessful">
                                <action execute="#{redirect.returnToCapturedView}"/>
                            </event>
                        • 9. Re: Token-based Remember-me is not working
                          guy bashan Apprentice

                          I am using Hibernate, so I don't have these lines:



                          <transaction:entity-transaction entity-manager="#{entityManager}"/>
                                                 <persistence:entity-manager-factory name="bookingDatabase"/>
                                   <persistence:managed-persistence-context name="entityManager"
                                                         auto-create="true"
                                              entity-manager-factory="#{bookingDatabase}"/>
                          



                          Do you think it matters?


                          • 10. Re: Token-based Remember-me is not working
                            Johnny Ren Newbie

                            Unfortunately, It does matters. JpaIdentityStore expects a Seam component named entityManager.  It uses the entityManager component to save and retrieve the token.

                            • 11. Re: Token-based Remember-me is not working
                              guy bashan Apprentice

                              Will changing the name of my Hibernate session factory to: entityManager help?
                              Sounds to me like it is a kind of bug in Seam code... Has anyone reported this issue yet?
                              By the way, can't I have this entity manager in Hibernate as well (instead of the session factory)?


                              Thanks,
                              Guy.

                              • 12. Re: Token-based Remember-me is not working
                                Shane Bryzak Master

                                The default component name that JpaTokenStore expects is entityManager, however you can configure this to be anything you like in components.xml.

                                • 13. Re: Token-based Remember-me is not working
                                  guy bashan Apprentice

                                  Hi Shane,
                                  of course I can configure it to anything I want, actually my component is name hibernateSession, since I am using Hibernate. The question is, how can I make the TokenBased to work, with a name different than entityManager? Is it possible to configure it to use a different name?

                                  • 14. Re: Token-based Remember-me is not working
                                    Shane Bryzak Master

                                    You need to put something like this in components.xml:




                                    <security:jpa-token-store entity-manager="#{hibernateSession}"/>



                                    1 2 Previous Next