java.lang.ClassCastException: com.icesoft.faces.webapp.http.portlet.InterceptingPortletSession

ICEsoft JIRA Issue Tracker | Deryk Sinotte | 9 years ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    Running the Download Resource example as a portlet causes this: 22:42:06,442 ERROR [jsp:52] java.lang.ClassCastException: com.icesoft.faces.webapp.http.portlet.InterceptingPortletSession at org.icefaces.application.showcase.view.bean.examples.component.outputResource.OutputResourceBean.<init>(OutputResourceBean.java:59) at java.lang.Class.newInstance0(Class.java:350) at java.lang.Class.newInstance(Class.java:303) at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:186) at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:106) at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:368) at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:230) at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:88) at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53) at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72) at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:61) at org.apache.el.parser.AstValue.getValue(AstValue.java:103) at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186) at com.sun.faces.application.ValueBindingValueExpressionAdapter.getValue(ValueBindingValueExpressionAdapter.java:113) at com.icesoft.faces.component.outputresource.OutputResource.getResource(OutputResource.java:66) at com.icesoft.faces.component.outputresource.OutputResourceRenderer.encodeBegin(OutputResourceRenderer.java:24) at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:813) at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:350) at com.icesoft.faces.renderkit.dom_html_basic.GridRenderer.encodeChildren(GridRenderer.java:203) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837) The culprit is the constructor for the OutputResourceBean: public OutputResourceBean(){ ServletContext context = ((HttpSession)FacesContext.getCurrentInstance().getExternalContext() .getSession(false)).getServletContext(); try{ imgResource = new ByteArrayResource( toByteArray( new FileInputStream( new File( context.getRealPath("/WEB-INF/resource/logo.jpg"))))); pdfResource = new FileResource( new File(context.getRealPath("/WEB-INF/resource/WP_Security_Whitepaper.pdf"))); pdfResourceDynFileName = new FileResource( new File(context.getRealPath("/WEB-INF/resource/WP_Security_Whitepaper.pdf"))); } catch(Exception e){ e.printStackTrace(); } } It tries to create these resources based on real file locations using ServletContext.getRealPath(). Using the Servlet API directly in this way makes it unsuitable for working as a portlet. PortletContext has a matching API so that would be one option to fix it. A better solution would be to do the straight JSF thing and use one of the ExternalContext.getResource* methods (getResource, getResourceAsStream, or getResourcePaths) and avoid having to check for which environment it's running in. I'm commenting out this portlet for the 1.7.2 release and will mark it as being re-introduced into the 1.8 release.

    ICEsoft JIRA Issue Tracker | 9 years ago | Deryk Sinotte
    java.lang.ClassCastException: com.icesoft.faces.webapp.http.portlet.InterceptingPortletSession
  2. 0

    Running the Download Resource example as a portlet causes this: 22:42:06,442 ERROR [jsp:52] java.lang.ClassCastException: com.icesoft.faces.webapp.http.portlet.InterceptingPortletSession at org.icefaces.application.showcase.view.bean.examples.component.outputResource.OutputResourceBean.<init>(OutputResourceBean.java:59) at java.lang.Class.newInstance0(Class.java:350) at java.lang.Class.newInstance(Class.java:303) at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:186) at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:106) at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:368) at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:230) at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:88) at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53) at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72) at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:61) at org.apache.el.parser.AstValue.getValue(AstValue.java:103) at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186) at com.sun.faces.application.ValueBindingValueExpressionAdapter.getValue(ValueBindingValueExpressionAdapter.java:113) at com.icesoft.faces.component.outputresource.OutputResource.getResource(OutputResource.java:66) at com.icesoft.faces.component.outputresource.OutputResourceRenderer.encodeBegin(OutputResourceRenderer.java:24) at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:813) at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:350) at com.icesoft.faces.renderkit.dom_html_basic.GridRenderer.encodeChildren(GridRenderer.java:203) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837) The culprit is the constructor for the OutputResourceBean: public OutputResourceBean(){ ServletContext context = ((HttpSession)FacesContext.getCurrentInstance().getExternalContext() .getSession(false)).getServletContext(); try{ imgResource = new ByteArrayResource( toByteArray( new FileInputStream( new File( context.getRealPath("/WEB-INF/resource/logo.jpg"))))); pdfResource = new FileResource( new File(context.getRealPath("/WEB-INF/resource/WP_Security_Whitepaper.pdf"))); pdfResourceDynFileName = new FileResource( new File(context.getRealPath("/WEB-INF/resource/WP_Security_Whitepaper.pdf"))); } catch(Exception e){ e.printStackTrace(); } } It tries to create these resources based on real file locations using ServletContext.getRealPath(). Using the Servlet API directly in this way makes it unsuitable for working as a portlet. PortletContext has a matching API so that would be one option to fix it. A better solution would be to do the straight JSF thing and use one of the ExternalContext.getResource* methods (getResource, getResourceAsStream, or getResourcePaths) and avoid having to check for which environment it's running in. I'm commenting out this portlet for the 1.7.2 release and will mark it as being re-introduced into the 1.8 release.

    ICEsoft JIRA Issue Tracker | 9 years ago | Deryk Sinotte
    java.lang.ClassCastException: com.icesoft.faces.webapp.http.portlet.InterceptingPortletSession

    Root Cause Analysis

    1. java.lang.ClassCastException

      com.icesoft.faces.webapp.http.portlet.InterceptingPortletSession

      at org.icefaces.application.showcase.view.bean.examples.component.outputResource.OutputResourceBean.<init>()
    2. org.icefaces.application
      OutputResourceBean.<init>
      1. org.icefaces.application.showcase.view.bean.examples.component.outputResource.OutputResourceBean.<init>(OutputResourceBean.java:59)
      1 frame
    3. Java RT
      Class.newInstance
      1. java.lang.Class.newInstance0(Class.java:350)
      2. java.lang.Class.newInstance(Class.java:303)
      2 frames
    4. JSF
      ManagedBeanELResolver.getValue
      1. com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:186)
      2. com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:106)
      3. com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:368)
      4. com.sun.faces.mgbean.BeanManager.create(BeanManager.java:230)
      5. com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:88)
      5 frames
    5. EL
      CompositeELResolver.getValue
      1. javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
      1 frame
    6. JSF
      FacesCompositeELResolver.getValue
      1. com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
      1 frame
    7. Pax Jsp
      ValueExpressionImpl.getValue
      1. org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:61)
      2. org.apache.el.parser.AstValue.getValue(AstValue.java:103)
      3. org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
      3 frames
    8. JSF
      ValueBindingValueExpressionAdapter.getValue
      1. com.sun.faces.application.ValueBindingValueExpressionAdapter.getValue(ValueBindingValueExpressionAdapter.java:113)
      1 frame
    9. com.icesoft.faces
      OutputResourceRenderer.encodeBegin
      1. com.icesoft.faces.component.outputresource.OutputResource.getResource(OutputResource.java:66)
      2. com.icesoft.faces.component.outputresource.OutputResourceRenderer.encodeBegin(OutputResourceRenderer.java:24)
      2 frames
    10. JavaEE 7
      UIComponentBase.encodeBegin
      1. javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:813)
      1 frame
    11. com.icesoft.faces
      GridRenderer.encodeChildren
      1. com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:350)
      2. com.icesoft.faces.renderkit.dom_html_basic.GridRenderer.encodeChildren(GridRenderer.java:203)
      2 frames
    12. JavaEE 7
      UIComponentBase.encodeChildren
      1. javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
      1 frame