Details
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);
}
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);
}
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