ICEfaces
  1. ICEfaces
  2. ICE-1234

NPE in BridgeExternalContext.addCookie()

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.2
    • Fix Version/s: 1.5.3
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      Operating System: Windows XP
      Platform: PC

      Description

      report came in from a client about an NPE when trying to set a cookie

      I am attempting to set a cookie using the following code:
       /**
           *
           */
          private void updateCookie()
          {
              Cookie userCookie = new Cookie("User", userid);
              userCookie.setMaxAge(60 * 60 * 24 * 365);
              ((BridgeExternalContext) FacesContext.getCurrentInstance()
                      .getExternalContext()).addCookie(userCookie);
          }

      When I run I am getting the following stack trace (NullPointerException).

      [2/1/07 10:13:55:265 CST] 0000002a jsf E
      com.sun.faces.lifecycle.InvokeApplicationPhase execute
      java.lang.NullPointerException
                                       javax.faces.el.EvaluationException:
      java.lang.NullPointerException
            at
      com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:131)
            at javax.faces.component.UICommand.broadcast(UICommand.java:305)
            at
      javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:302)
            at
      javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:416)
            at
      com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77)
            at
      com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:220)
            at
      com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:91)
            at
      com.icesoft.faces.webapp.xmlhttp.BlockingServlet.renderCycle(Unknown
      Source)
            at
      com.icesoft.faces.webapp.xmlhttp.BlockingServlet.receiveUpdates(Unknown
      Source)
            at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(Unknown
      Source)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
            at
      com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1282)
            at
      com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1239)
            at
      com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:113)
            at
      com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:82)
            at
      com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:670)
            at
      com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:2933)
            at
      com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:221)
            at
      com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:210)
            at
      com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1912)
            at
      com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:84)
            at
      com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:472)
            at
      com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:411)
            at
      com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:101)
            at
      com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:566)
            at
      com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java:619)
            at
      com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:952)
            at
      com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1039)
            at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1462)
      Caused by: java.lang.NullPointerException
            at com.icesoft.faces.context.BridgeExternalContext.addCookie(Unknown
      Source)
            at
      gov.mo.modot.budget.control.ProfileBean.updateCookie(ProfileBean.java)
            at
      gov.mo.modot.budget.control.ProfileBean.login(ProfileBean.java:205)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
            at
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
            at
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
            at java.lang.reflect.Method.invoke(Method.java:391)
            at
      com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:127)
            at javax.faces.component.UICommand.broadcast(UICommand.java:305)
            at
      javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:302)
            at
      javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:416)
            at
      com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77)
            at
      com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:220)
            at
      com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:91)
            at
      com.icesoft.faces.webapp.xmlhttp.BlockingServlet.renderCycle(Unknown
      Source)
            at
      com.icesoft.faces.webapp.xmlhttp.BlockingServlet.receiveUpdates(Unknown
      Source)
            at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(Unknown
      Source)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
            at
      com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1282)
            at
      com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1239)
            at
      com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:113)
            at
      com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:82)
            at
      com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:670)
            at
      com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:2933)
            at
      com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:221)
            at
      com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:210)
            at
      com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1912)
            at
      com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:84)
            at
      com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:472)
            at
      com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:411)
            at
      com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:101)
            at
      com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:566)
            at
      com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java:619)
            at
      com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:952)
            at
      com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1039)
            at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1462)

      responseCookieMap is null so I guess we might want to call
      getResponseCookieMap(), which creates the hashtable if it's null, in addCookie()
       instead of referencing responseCookieMap directly:

      public void addCookie(Cookie cookie) {
              getResponseCookieMap().put(cookie.getName(), cookie);
          }

        Activity

        Ken Fyten made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Icefaces Administrator made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 1304 12503
        Philip Breau created issue -

          People

          • Assignee:
            Philip Breau
            Reporter:
            Philip Breau
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: