title: IBM JSF PortletSession is null
body: <p>We use <strong>IBM WebSphere Portal</strong> in combination with <code>JSF</code>. A <em>dreadful</em> mix, which keeps proving its dreadfulness time after time.</p>
  
  <p>Recently we're having the issue where we have a portlet with a <em>link</em> to a <em>download servlet</em> (contained in the <em>same war</em>). This <em>servlet</em> tries to read <em>certain attributes</em> from the <em>HttpSession</em> which are supposed to be set by the <em>portlet</em> on the <em>PortletSession</em> in <code>APPLICATION_SCOPE</code>.</p>
  
  <p>Sometimes, however, the <em>servlet</em> couldn't <em>read</em> any of the needed attributes from the <em><code>HttpSession</code></em>. This was cause for an <em>investigation</em> by me. After some searching I discovered that it only happened when the <em>portlet</em> was <em>loaded</em> for the <em>first time</em> (without any page reloads).</p>
  
  <p>After some experimenting I got a <code>NullPointerException</code> when calling <code>getAttributeNames(scope)</code> on the <code>PortletSession</code>. The <code>PortletSession</code> was obtained from the <em>external context</em> through the <em>faces context</em>.  I discovered the <code>PortletSession</code> was in fact a  <code>com.ibm.faces.portlet.httpbridge.PortletSessionWrapper</code> which apparently is <em>supposed to contain</em> the actual <code>PortletSession</code>. This contained <em>session</em> was clearly <strong>null</strong>. Most methods of the <code>PortletSessionWrapper</code> guard against an <em>NPE</em> with a null check, however, the <code>getAttributeNames(scope)</code>  didn't (a bug if you ask me). </p>
  
  <p><strong>Now is the big question:</strong> why is the (real) <code>PortletSession</code> <strong><em>null</em></strong> on the <em>first load</em> of the <em>portlet</em> ?</p>
  
  <p>The <code>META-INF</code> of the <em>jsf-protletbrdige</em> providing the wrapper:</p>
  
  <blockquote>
    <p>Manifest-Version: 1.0<br/> Ant-Version: Apache Ant 1.7.1<br/>
    Created-By: IBM Corporation<br/> Specification-Title: Java Server
    Faces<br/> Implementation-Title: JSF Widget Library (JWL) - Portlet
    Bridge<br/> Implementation-Version: JWL v3_1_5<br/>
    Implementation-Vendor: IBM<br/> Build-Version: 20100212_0941<br/>
    Build-Date: February 12 2010<br/> Copyright-Info: Copyright (c)
    2003,2008, International Business Machines Corporation.  All Rights
    Reserved.</p>
  </blockquote>
  
  <p>The stacktrace when calling the getAttributeNames(scope) method:</p>
  
  <pre><code>[21-8-12 17:52:16:051 CEST] 00000041 servlet       E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E: Uncaught exception created in one of the service methods of the servlet Header in application PA_mytestportlet. Exception created : javax.servlet.ServletException: javax.portlet.PortletException: /MyPortletView.jsp(105,9) '#{MyPortletView.productId}' Error reading 'productId' on type mytest.portal.testportlet.view.MyPortletViewBean
      at com.ibm.ws.portletcontainer.invoker.impl.PortletServlet.doDispatch(PortletServlet.java:361)
      at com.ibm.ws.portletcontainer.invoker.impl.PortletServletCollaboratorChainImpl.doCollaborator(PortletServletCollaboratorChainImpl.java:82)
      at com.ibm.isclite.container.collaborator.PortletServletCollaborator.doDispatch(PortletServletCollaborator.java:143)
      at com.ibm.ws.portletcontainer.invoker.impl.PortletServletCollaboratorChainImpl.doCollaborator(PortletServletCollaboratorChainImpl.java:74)
      at com.ibm.ws.portletcontainer.rrd.RRDServerPortletServletCollaborator.doDispatch(RRDServerPortletServletCollaborator.java:60)
      at com.ibm.ws.portletcontainer.invoker.impl.PortletServletCollaboratorChainImpl.doCollaborator(PortletServletCollaboratorChainImpl.java:74)
      at com.ibm.ws.portletcontainer.cache.CacheCollaborator.doDispatch(CacheCollaborator.java:74)
      at com.ibm.ws.portletcontainer.invoker.impl.PortletServletCollaboratorChainImpl.doCollaborator(PortletServletCollaboratorChainImpl.java:74)
      at com.ibm.wps.pe.pc.waspc.core.impl.PortletServletCollaboratorImpl.doDispatch(PortletServletCollaboratorImpl.java:121)
      at com.ibm.ws.portletcontainer.invoker.impl.PortletServletCollaboratorChainImpl.doCollaborator(PortletServletCollaboratorChainImpl.java:74)
      at com.ibm.ws.portletcontainer.invoker.impl.PortletServlet.dispatch(PortletServlet.java:208)
      at com.ibm.ws.portletcontainer.invoker.impl.PortletServlet.service(PortletServlet.java:165)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1657)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1597)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:104)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:77)
      at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:908)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:934)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:502)
      at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:179)
      at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:121)
      at com.ibm.ws.portletcontainer.webextension.PortletExtensionProcessor.handleRequest(PortletExtensionProcessor.java:86)
      at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:686)
      at com.ibm.ws.portletcontainer.invoker.impl.PortletInvokerImpl.invoke(PortletInvokerImpl.java:214)
      at com.ibm.ws.portletcontainer.invoker.impl.PortletInvokerCollaboratorChainImpl.doCollaborator(PortletInvokerCollaboratorChainImpl.java:78)
      at com.ibm.ws.portletcontainer.cache.PortletInvokerCacheCollaborator.doRender(PortletInvokerCacheCollaborator.java:58)
      at com.ibm.ws.portletcontainer.invoker.impl.PortletInvokerCollaboratorChainImpl.doCollaborator(PortletInvokerCollaboratorChainImpl.java:67)
      at com.ibm.ws.portletcontainer.ext.PortletInvokerPerformanceCollaborator.invoke(PortletInvokerPerformanceCollaborator.java:313)
      at com.ibm.ws.portletcontainer.ext.PortletInvokerPerformanceCollaborator.doInvoke(PortletInvokerPerformanceCollaborator.java:101)
      at com.ibm.ws.portletcontainer.ext.PortletInvokerPerformanceCollaborator.invokePMI(PortletInvokerPerformanceCollaborator.java:163)
      at com.ibm.ws.portletcontainer.ext.PortletInvokerPerformanceCollaborator.doInvoke(PortletInvokerPerformanceCollaborator.java:91)
      at com.ibm.ws.portletcontainer.ext.PortletInvokerPerformanceCollaborator.doRender(PortletInvokerPerformanceCollaborator.java:74)
      at com.ibm.ws.portletcontainer.invoker.impl.PortletInvokerCollaboratorChainImpl.doCollaborator(PortletInvokerCollaboratorChainImpl.java:67)
      at com.ibm.ws.portletcontainer.invoker.impl.PortletInvokerImpl.render(PortletInvokerImpl.java:97)
      at com.ibm.ws.portletcontainer.PortletContainerImpl.doRender(PortletContainerImpl.java:121)
      at com.ibm.ws.portletcontainer.PortletContainerInvokerCollaboratorChainImpl.doCollaborator(PortletContainerInvokerCollaboratorChainImpl.java:80)
      at com.ibm.ws.portletcontainer.ext.ExtCollaborator.doRender(ExtCollaborator.java:74)
      at com.ibm.ws.portletcontainer.PortletContainerInvokerCollaboratorChainImpl.doCollaborator(PortletContainerInvokerCollaboratorChainImpl.java:67)
      at com.ibm.ws.portletcontainer.cache.CacheInvokerCollaborator.doRender(CacheInvokerCollaborator.java:66)
      at com.ibm.ws.portletcontainer.PortletContainerInvokerCollaboratorChainImpl.doCollaborator(PortletContainerInvokerCollaboratorChainImpl.java:67)
      at com.ibm.ws.portletcontainer.PortletContainerImpl.renderPortlet(PortletContainerImpl.java:91)
      at com.ibm.ws.portletcontainer.pcinvoker.PortletInvokerImpl$2.run(PortletInvokerImpl.java:100)
      at java.security.AccessController.doPrivileged(AccessController.java:251)
      at com.ibm.ws.portletcontainer.pcinvoker.PortletInvokerImpl.invokeRender(PortletInvokerImpl.java:96)
      at com.ibm.wps.pe.pc.waspc.core.impl.PortletInvokerImpl$1.invoke(PortletInvokerImpl.java:98)
      at com.ibm.wps.pe.pc.waspc.core.impl.PortletInvokerImpl.invoke(PortletInvokerImpl.java:181)
      at com.ibm.wps.pe.pc.waspc.core.impl.PortletInvokerImpl.invokeRender(PortletInvokerImpl.java:96)
      at com.ibm.wps.pe.pc.waspc.PortletContainerImpl.renderPortlet(PortletContainerImpl.java:116)
      at com.ibm.wps.pe.pc.PortletContainerImpl.doRenderPortlet(PortletContainerImpl.java:641)
      at com.ibm.wps.pe.ext.render.AbstractRenderManager.performService(AbstractRenderManager.java:264)
      at com.ibm.wps.pe.pc.PortletContainerImpl.renderPortlet(PortletContainerImpl.java:132)
      at com.ibm.wps.engine.tags.PortletRenderTag.doStartTag(PortletRenderTag.java:179)
      at com.ibm._jsp._Control._jspx_meth_portal$1skin_portletRender_0(_Control.java:276)
      at com.ibm._jsp._Control._jspx_meth_portal$1logic_if_1(_Control.java:315)
      at com.ibm._jsp._Control._jspService(_Control.java:168)
      at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:99)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1657)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:939)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:502)
      at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:179)
      at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:121)
      at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:259)
      at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:686)
      at com.ibm.wps.services.dispatcher.DispatcherServiceImpl.handleRequest(DispatcherServiceImpl.java:93)
      at com.ibm.wps.services.dispatcher.DispatcherServiceImpl.include(DispatcherServiceImpl.java:53)
      at com.ibm.wps.services.dispatcher.Dispatcher.include(Dispatcher.java:50)
      at com.ibm.wps.engine.templates.skins.Default.render(Default.java:154)
      at com.ibm.wps.engine.templates.SkinTemplate.render(SkinTemplate.java:68)
      at com.ibm.wps.composition.elements.Component.render(Component.java:638)
      at com.ibm.wps.composition.elements.Control.render(Control.java:159)
      at com.ibm.wps.composition.Composition.render(Composition.java:3102)
      at com.ibm.wps.composition.Composition.render(Composition.java:163)
      at com.ibm.websphere.personalization.transformation.PznTransformationLayoutModel.render(PznTransformationLayoutModel.java:90)
      at com.ibm.wps.model.wrappers.LayoutModelWrapperFactoryImpl$LayoutModelWrapperImpl.render(LayoutModelWrapperFactoryImpl.java:275)
      at com.ibm.wps.model.ModelUtil$WrappedCompositionModel.render(ModelUtil.java:1124)
      at com.ibm._jsp._UnlayeredContainer_2D_H._jspService(_UnlayeredContainer_2D_H.java:224)
      at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:99)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1657)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:939)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:502)
      at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:179)
      at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:121)
      at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:259)
      at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:686)
      at com.ibm.wps.services.dispatcher.DispatcherServiceImpl.handleRequest(DispatcherServiceImpl.java:93)
      at com.ibm.wps.services.dispatcher.DispatcherServiceImpl.include(DispatcherServiceImpl.java:53)
      at com.ibm.wps.services.dispatcher.Dispatcher.include(Dispatcher.java:50)
      at com.ibm.wps.engine.templates.skins.Default.render(Default.java:154)
      at com.ibm.wps.engine.templates.SkinTemplate.render(SkinTemplate.java:68)
      at com.ibm.wps.composition.elements.Component.render(Component.java:638)
      at com.ibm.wps.composition.Composition.render(Composition.java:3102)
      at com.ibm.wps.composition.Composition.render(Composition.java:163)
      at com.ibm.websphere.personalization.transformation.PznTransformationLayoutModel.render(PznTransformationLayoutModel.java:90)
      at com.ibm.wps.model.wrappers.LayoutModelWrapperFactoryImpl$LayoutModelWrapperImpl.render(LayoutModelWrapperFactoryImpl.java:275)
      at com.ibm.wps.model.ModelUtil$WrappedCompositionModel.render(ModelUtil.java:1124)
      at com.ibm._jsp._UnlayeredContainer_2D_V._jspService(_UnlayeredContainer_2D_V.java:215)
      at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:99)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1657)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:939)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:502)
      at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:179)
      at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:121)
      at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:259)
      at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:686)
      at com.ibm.wps.services.dispatcher.DispatcherServiceImpl.handleRequest(DispatcherServiceImpl.java:93)
      at com.ibm.wps.services.dispatcher.DispatcherServiceImpl.include(DispatcherServiceImpl.java:53)
      at com.ibm.wps.services.dispatcher.Dispatcher.include(Dispatcher.java:50)
      at com.ibm.wps.engine.templates.skins.Default.render(Default.java:154)
      at com.ibm.wps.engine.templates.SkinTemplate.render(SkinTemplate.java:68)
      at com.ibm.wps.composition.elements.Component.render(Component.java:638)
      at com.ibm.wps.composition.Composition.render(Composition.java:3102)
      at com.ibm.wps.composition.Composition.render(Composition.java:163)
      at com.ibm.websphere.personalization.transformation.PznTransformationLayoutModel.render(PznTransformationLayoutModel.java:90)
      at com.ibm.wps.model.wrappers.LayoutModelWrapperFactoryImpl$LayoutModelWrapperImpl.render(LayoutModelWrapperFactoryImpl.java:275)
      at com.ibm.wps.engine.tags2.PageRenderTag.doStartTag(PageRenderTag.java:534)
      at com.ibm._jsp._Home._jspService(_Home.java:104)
      at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:99)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1657)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:939)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:502)
      at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:179)
      at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:121)
      at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:259)
      at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:686)
      at com.ibm.wps.services.dispatcher.DispatcherServiceImpl.handleRequest(DispatcherServiceImpl.java:93)
      at com.ibm.wps.services.dispatcher.DispatcherServiceImpl.include(DispatcherServiceImpl.java:53)
      at com.ibm.wps.services.dispatcher.Dispatcher.include(Dispatcher.java:50)
      at com.ibm.wps.engine.templates.screens.Default.render(Default.java:133)
      at com.ibm.wps.engine.templates.ScreenTemplate.render(ScreenTemplate.java:59)
      at com.ibm.wps.engine.tags2.ScreenRenderTag.doStartTag(ScreenRenderTag.java:182)
      at com.ibm._jsp._Default._jspx_meth_portal$1core_screenRender_0(_Default.java:3623)
      at com.ibm._jsp._Default._jspService(_Default.java:1966)
      at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:99)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1657)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:939)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:502)
      at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:179)
      at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:121)
      at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:259)
      at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:686)
      at com.ibm.wps.services.dispatcher.DispatcherServiceImpl.handleRequest(DispatcherServiceImpl.java:93)
      at com.ibm.wps.services.dispatcher.DispatcherServiceImpl.include(DispatcherServiceImpl.java:53)
      at com.ibm.wps.services.dispatcher.Dispatcher.include(Dispatcher.java:50)
      at com.ibm.wps.engine.templates.themes.Default.doDispatch(Default.java:294)
      at com.ibm.wps.engine.templates.themes.Default.render(Default.java:247)
      at com.ibm.wps.engine.templates.ThemeTemplate.render(ThemeTemplate.java:65)
      at com.ibm.wps.engine.phases.WPRenderPhase.processRendering(WPRenderPhase.java:509)
      at com.ibm.wps.engine.phases.WPBaseRenderPhase.execute(WPBaseRenderPhase.java:194)
      at com.ibm.wps.state.phases.AbstractRenderPhase.next(AbstractRenderPhase.java:106)
      at com.ibm.wps.engine.phases.WPAbstractRenderPhase.next(WPAbstractRenderPhase.java:97)
      at com.ibm.wps.engine.Servlet.callPortal(Servlet.java:860)
      at com.ibm.wps.engine.Servlet.doGet(Servlet.java:617)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
      at com.ibm.wps.engine.Servlet.doFilter(Servlet.java:1257)
      at com.ibm.wps.resolver.servlet.ContentHandlerCleanup.doFilter(ContentHandlerCleanup.java:648)
      at com.ibm.wps.resolver.servlet.AbstractFilter.doFilter(AbstractFilter.java:93)
      at com.ibm.wps.engine.Servlet.service(Servlet.java:1248)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1657)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1597)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:131)
      at com.ibm.wps.engine.ExtendedLocaleFilter.doFilter(ExtendedLocaleFilter.java:113)
      at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)
      at com.ibm.wps.resolver.friendly.servlet.FriendlySelectionFilter.doFilter(FriendlySelectionFilter.java:191)
      at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)
      at com.ibm.wps.mappingurl.impl.URLAnalyzer.doFilter(URLAnalyzer.java:381)
   . . .
  Caused by: javax.portlet.PortletException: /MyPortletView.jsp(105,9) '#{MyPortletView.productId}' Error reading 'productId' on type mytest.portal.testportlet.view.MyPortletViewBean
      at com.ibm.faces.portlet.FacesPortlet.doRender(FacesPortlet.java:384)
      at com.ibm.faces.portlet.FacesPortlet.doView(FacesPortlet.java:413)
      at com.ibm.faces.portlet.FacesPortlet.doDispatch(FacesPortlet.java:301)
      at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
      at mytest.portal.testportlet.portlet.HeaderPortlet.render(HeaderPortlet.java:44)
      at com.ibm.ws.portletcontainer.invoker.impl.PortletFilterChainImpl.doFilter(PortletFilterChainImpl.java:128)
      at com.ibm.wps.propertybroker.standard.filter.C2APortletFilter.doFilter(C2APortletFilter.java:183)
      at com.ibm.ws.portletcontainer.invoker.impl.PortletFilterChainImpl.doFilter(PortletFilterChainImpl.java:120)
      at com.ibm.ws.portletcontainer.invoker.impl.PortletServlet.doDispatch(PortletServlet.java:573)
      at com.ibm.ws.portletcontainer.invoker.impl.PortletServletCollaboratorChainImpl.doCollaborator(PortletServletCollaboratorChainImpl.java:114)
      at com.ibm.isclite.container.collaborator.PortletServletCollaborator.doRender(PortletServletCollaborator.java:71)
      at com.ibm.ws.portletcontainer.invoker.impl.PortletServletCollaboratorChainImpl.doCollaborator(PortletServletCollaboratorChainImpl.java:105)
      at com.ibm.ws.portletcontainer.rrd.RRDServerPortletServletCollaborator.doRender(RRDServerPortletServletCollaborator.java:123)
      at com.ibm.ws.portletcontainer.invoker.impl.PortletServletCollaboratorChainImpl.doCollaborator(PortletServletCollaboratorChainImpl.java:105)
      at com.ibm.ws.portletcontainer.cache.CacheCollaborator.doRender(CacheCollaborator.java:92)
      at com.ibm.ws.portletcontainer.invoker.impl.PortletServletCollaboratorChainImpl.doCollaborator(PortletServletCollaboratorChainImpl.java:105)
      at com.ibm.wps.pe.pc.waspc.core.impl.PortletServletCollaboratorImpl.doRender(PortletServletCollaboratorImpl.java:156)
      at com.ibm.ws.portletcontainer.invoker.impl.PortletServletCollaboratorChainImpl.doCollaborator(PortletServletCollaboratorChainImpl.java:105)
      at com.ibm.ws.portletcontainer.invoker.impl.PortletServlet.doDispatch(PortletServlet.java:273)
      ... 203 more
  Caused by: org.apache.jasper.el.JspELException: /MyPortletView.jsp(105,9) '#{MyPortletView.productId}' Error reading 'productId' on type mytest.portal.testportlet.view.MyPortletViewBean
      at org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:106)
      at javax.faces.component.UIParameter.getValue(UIParameter.java:167)
      at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getParamList(HtmlBasicRenderer.java:518)
      at com.sun.faces.renderkit.html_basic.OutputLinkRenderer.renderAsActive(OutputLinkRenderer.java:203)
      at com.sun.faces.renderkit.html_basic.OutputLinkRenderer.encodeBegin(OutputLinkRenderer.java:100)
      at com.ibm.faces.renderkit.DefaultAjaxRenderer.encodeBegin(DefaultAjaxRenderer.java:64)
      at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:812)
      at mytest.jsf.util.ChildRendererUtil.renderChildren(ChildRendererUtil.java:45)
      at mytest.portal.ui.jsf.custom.component.htmltag.HtmlTagRenderer.encodeChildren(HtmlTagRenderer.java:110)
      at com.ibm.faces.renderkit.DefaultAjaxRenderer.encodeChildren(DefaultAjaxRenderer.java:73)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:836)
      at mytest.jsf.util.ChildRendererUtil.renderChildren(ChildRendererUtil.java:47)
      at mytest.portal.ui.jsf.custom.component.htmltag.HtmlTagRenderer.encodeChildren(HtmlTagRenderer.java:110)
      at com.ibm.faces.renderkit.DefaultAjaxRenderer.encodeChildren(DefaultAjaxRenderer.java:73)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:836)
      at mytest.jsf.util.ChildRendererUtil.renderChildren(ChildRendererUtil.java:47)
      at mytest.portal.ui.jsf.custom.component.htmltag.HtmlTagRenderer.encodeChildren(HtmlTagRenderer.java:110)
      at com.ibm.faces.renderkit.DefaultAjaxRenderer.encodeChildren(DefaultAjaxRenderer.java:73)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:836)
      at mytest.jsf.util.ChildRendererUtil.renderChildren(ChildRendererUtil.java:47)
      at mytest.portal.ui.jsf.custom.component.htmltag.HtmlTagRenderer.encodeChildren(HtmlTagRenderer.java:110)
      at com.ibm.faces.renderkit.DefaultAjaxRenderer.encodeChildren(DefaultAjaxRenderer.java:73)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:836)
      at mytest.jsf.util.ChildRendererUtil.renderChildren(ChildRendererUtil.java:47)
      at mytest.portal.ui.jsf.custom.component.htmltag.HtmlTagRenderer.encodeChildren(HtmlTagRenderer.java:110)
      at com.ibm.faces.renderkit.DefaultAjaxRenderer.encodeChildren(DefaultAjaxRenderer.java:73)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:836)
      at mytest.jsf.util.ChildRendererUtil.renderChildren(ChildRendererUtil.java:47)
      at mytest.portal.ui.jsf.custom.component.htmltag.HtmlTagRenderer.encodeChildren(HtmlTagRenderer.java:110)
      at com.ibm.faces.renderkit.DefaultAjaxRenderer.encodeChildren(DefaultAjaxRenderer.java:73)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:836)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:942)
      at javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
      at com.ibm.faces.renderkit.DefaultAjaxRenderer.encodeChildren(DefaultAjaxRenderer.java:73)
      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:836)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:942)
      at com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:292)
      at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:223)
      at com.ibm.faces.portlet.PortletViewHandlerImpl.renderView(PortletViewHandlerImpl.java:79)
      at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:114)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
      at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
      at com.ibm.faces.portlet.FacesPortlet.doRender(FacesPortlet.java:372)
      ... 221 more
  Caused by: java.lang.NullPointerException
      at com.ibm.faces.portlet.httpbridge.PortletSessionWrapper.getAttributeNames(PortletSessionWrapper.java:185)
      at mytest.portal.testportlet.view.MyPortletViewBean.getProductId(MyPortletViewBean.java:394)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
      at java.lang.reflect.Method.invoke(Method.java:611)
      at javax.el.BeanELResolver.getValue(BeanELResolver.java:64)
      at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:143)
      at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:73)
      at org.apache.el.parser.AstValue.getValue(AstValue.java:102)
      at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:263)
      at org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:100)
      ... 265 more
  </code></pre>
  
  <p>The session scope is obtained using the following code:</p>
  
  <pre><code>FacesContext facesContext = getFacesContext();
  if (facesContext != null) {
      return (PortletSession) facesContext.getExternalContext().getSession(createIfNotExist);
   }
   return null;
  </code></pre>
  
  <p>where <code>createIfNotExist</code> is <strong>false</strong>.</p>