[jboss-user] [JBoss Seam] - Remember Me Exception

PatrickMadden do-not-reply at jboss.com
Tue Mar 6 22:42:54 EST 2007


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

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4025658#4025658

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4025658



More information about the jboss-user mailing list