8 Replies Latest reply on Apr 30, 2007 3:18 PM by Monkey Den

    Remember Me Exception

    Patrick Madden Newbie

      Hi, I have a strange null pointer exception when trying to implement the Remember Me functionality.

      It seems to be a null pointer exception in org.jboss.seam.core.Selector.setCookieValue(Selector:77). I've looked at the code and it appears that the response object is null which to me is strange.

      Below is the method in Seam that is "causing" the problem.

      I'm using Seam 1.2 patched and IceFaces 1.5.3

       /**
       * Set the cookie
       */
       protected void setCookieValue(String value)
       {
       if ( isCookieEnabled() )
       {
       HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
       Cookie cookie = new Cookie( getCookieName(), value );
       cookie.setMaxAge( getCookieMaxAge() );
       response.addCookie(cookie); /* NPE IS RIGHT HERE */
       }
       }
      


      I have no idea why the response would be null at this point in time. My login works fine and authenticates correctly. Only dumps if I have the remember me check box selected.

      For completeness I'll list the full stack trace here:


      22:21:11,867 ERROR [[Blocking Servlet]] Servlet.service() for servlet Blocking Servlet threw exception
      javax.faces.FacesException: Error calling action method of component with id _id32:_id56
       at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
       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 com.icesoft.faces.webapp.xmlhttp.BlockingServlet.renderCycle(BlockingServlet.java:438)
       at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.receiveUpdates(BlockingServlet.java:426)
       at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:279)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       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:595)
      Caused by: javax.faces.el.EvaluationException: /login.xhtml @59,93 action="#{identity.login}": java.lang.NullPointerException
       at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:73)
       at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
       ... 29 more
      Caused by: java.lang.NullPointerException
       at org.jboss.seam.core.Selector.setCookieValue(Selector.java:77)
       at org.jboss.seam.security.Identity.postAuthenticate(Identity.java:284)
       at org.jboss.seam.security.RuleBasedIdentity.postAuthenticate(RuleBasedIdentity.java:70)
       at org.jboss.seam.security.Identity.authenticate(Identity.java:250)
       at org.jboss.seam.security.Identity.authenticate(Identity.java:242)
       at org.jboss.seam.security.Identity.login(Identity.java:172)
       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)
       ... 30 more
      


      And here is my login form:

       <h:form>
      
       <div class="dialog">
       <div class="entry">
       <div class="label">
       <h:outputText value="#{messages['login.name']}" />
       </div>
       <div class="input">
       <h:inputText id="username" value="#{identity.username}"/>
       </div>
       </div>
       <div class="entry">
       <div class="label">
       <h:outputText value="#{messages['login.password']}" />
       </div>
       <div class="input">
       <h:inputSecret id="password" value="#{identity.password}"/>
       </div>
       </div>
       <div class="entry">
       <div class="label">
       <h:outputText value="#{messages['login.rememberMe']}" />
       </div>
       <div class="input">
       <h:selectBooleanCheckbox id="rememberMe" value="#{identity.rememberMe}"/>
       </div>
       </div>
       <div class="entry">
       <div>
       <h:graphicImage value="/seam/resource/captcha?#{captcha.id}"/>
       </div>
       <div class="label">
       <h:outputLabel for="verifyCaptcha">Enter the above letters</h:outputLabel>
       </div>
       <div class="input">
       <h:inputText id="verifyCaptcha" value="#{captcha.response}" required="true"/>
       </div>
       <div class="errors"><h:message for="verifyCaptcha"/></div>
       </div>
       </div>
      
       <div class="actionButtons">
       <h:commandButton value="#{messages['login.login']}" action="#{identity.login}"/>
       </div>
      
       <div class="actionButtons">
       <s:link view="/registerUser.xhtml" value="#{messages['registerUser.new']}" />
       </div>
      
       </h:form>
      


      Any help is greatly appreciated,

      PVM

        • 1. Re: Remember Me Exception
          Pete Muir Master

          Does it work without icefaces in the mix? If so report a bug in the seam icefaces integration component of JIRA

          • 2. Re: Remember Me Exception
            Greg Zoller Newbie

            Patrick,

            I'm getting the exact same exception. Were you able to find a workaround or identify if it was IceFaces-related?

            Greg

            • 3. Re: Remember Me Exception
              Patrick Madden Newbie

              Greg,

              Haven't had a chance to test it ouside of icefaces yet. It more than likely is some integration issue - I may try the developer release (1.6) of ice to see if it solves the problem.

              Will let you know,

              PVM

              • 4. Re: Remember Me Exception
                Jay Scherer Newbie

                Having the same issue here. Any resolution to this issue???

                • 5. Re: Remember Me Exception
                  Greg Zoller Newbie

                  I pulled out IceFaces and tried it with the vanilla Seam-gen. Worked great. IceFaces is the culprit here.

                  {rant}
                  Y'know... I'm getting a bit flustered w/IceFaces. Great widgets but Seam integration is pretty flaky. Even tried the alpha of their next release--still lots of stability issues--not ready for production use. As great a union as these two technologies would make, it would appear there are still some key disconnects in their implementations. I'll watch future releases--I do love their widgets, but for now I've started playing with Ajax4JSF and RichFaces. Still having newbie issues--we'll see how that goes. I can't get things rendering/behaving how I want but so far no gonzo exceptions, so that's a good sign.
                  {/rant}

                  • 6. Seam-gen Login
                    eeckmann Newbie

                    How do you pull out IceFaces ?

                    I am getting this msg when trying to login (with and without the Remember me checked):

                    Caused by: javax.faces.el.PropertyNotFoundException: Base is null: authenticator
                    at org.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(ValueBindingImpl.java:460)
                    at org.apache.myfaces.el.MethodBindingImpl.resolveToBaseAndProperty(MethodBindingImpl.java:180)
                    at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:114)
                    ... 67 more

                    • 7. Re: Remember Me Exception
                      Patrick Ruhkopf Newbie

                      I?ve just encountered the same PropertyNotFoundException although I don't use IceFaces. So this might not solve the original problem but maybe helps people searching for this exception.

                      I actually forgot to put seam.properties in my classpath and thus seam wasn't aware of my annotated authenticator. To be honest, I didn't even know about the properties file in the first place. Section 21.1.6. Don't forget! of the manual should IMHO be the very first paragraph, red letters and bold! ;-)

                      • 8. Re: Remember Me Exception
                        Monkey Den Master

                        Anyone found a resolution to this?