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

        Hide
        Philip Breau added a comment -

        Hi Randy,
        Thanks for reporting this. I've opened up support case #3873 for this issue.
        The issue comes from the BridgeExternalContext not checking if it's
        responseCookieMap has been initialized in addCookie(). I've patched our 1.5.2
        icefaces.jar. Could you give this a try and let me know if it solves the issue?

        Regards,
        Philip

        Show
        Philip Breau added a comment - Hi Randy, Thanks for reporting this. I've opened up support case #3873 for this issue. The issue comes from the BridgeExternalContext not checking if it's responseCookieMap has been initialized in addCookie(). I've patched our 1.5.2 icefaces.jar. Could you give this a try and let me know if it solves the issue? Regards, Philip
        Hide
        Ted Goddard added a comment -

        The suggested fix looks good.

        Show
        Ted Goddard added a comment - The suggested fix looks good.
        Hide
        Ken Fyten added a comment -

        Who's going to commit the fix to the 1.5 branch, Ted?

        Show
        Ken Fyten added a comment - Who's going to commit the fix to the 1.5 branch, Ted?
        Hide
        Philip Breau added a comment -

        committed fix in 13092

        Show
        Philip Breau added a comment - committed fix in 13092
        Hide
        Ken Fyten added a comment -

        This needs to be committed to both the 1.5 branch and the head. Please post a
        clarifying statement regarding the related revision numbers for both commits.

        Show
        Ken Fyten added a comment - This needs to be committed to both the 1.5 branch and the head. Please post a clarifying statement regarding the related revision numbers for both commits.
        Hide
        Philip Breau added a comment -

        I don't think it applies to the head, as the head doesn't have the addCookie()
        support

        Show
        Philip Breau added a comment - I don't think it applies to the head, as the head doesn't have the addCookie() support
        Hide
        Ken Fyten added a comment -

        Fixed in 1.5.3.

        Show
        Ken Fyten added a comment - Fixed in 1.5.3.
        Hide
        Philip Breau added a comment -

        verified
        win xp, jboss 4.0.5, ff

        Show
        Philip Breau added a comment - verified win xp, jboss 4.0.5, ff

          People

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

            Dates

            • Created:
              Updated:
              Resolved: