Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Invalid
-
Affects Version/s: 1.7.2
-
Fix Version/s: 1.8DR#2
-
Component/s: Sample Apps
-
Labels:None
-
Environment:Component Showcase portlet
-
Assignee Priority:P2
-
Affects:Sample App./Tutorial
Description
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.
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.
Activity
Repository | Revision | Date | User | Message |
ICEsoft Public SVN Repository | #17730 | Tue Oct 07 09:41:47 MDT 2008 | deryk.sinotte | |
Files Changed | ||||
MODIFY
/icefaces/branches/icefaces-1.7/icefaces/samples/component-showcase/portlets/conf/liferay/liferay-portlet.xml
MODIFY /icefaces/branches/icefaces-1.7/icefaces/samples/component-showcase/portlets/conf/portlet.xml MODIFY /icefaces/branches/icefaces-1.7/icefaces/samples/component-showcase/portlets/conf/liferay/liferay-display.xml |
Deryk Sinotte
created issue -
Deryk Sinotte
made changes -
Field | Original Value | New Value |
---|---|---|
Component/s | Sample Apps [ 10010 ] | |
Fix Version/s | 1.8DR#1 [ 10141 ] | |
Affects | [Sample App./Tutorial] | |
Assignee Priority | P1 | |
Assignee | Ken Fyten [ ken.fyten ] |
Ken Fyten
made changes -
Fix Version/s | 1.8DR#2 [ 10142 ] | |
Fix Version/s | 1.8DR#1 [ 10141 ] |
Ken Fyten
made changes -
Assignee | Ken Fyten [ ken.fyten ] | Deryk Sinotte [ deryk.sinotte ] |
Deryk Sinotte
made changes -
Assignee | Deryk Sinotte [ deryk.sinotte ] | Philip Breau [ philip.breau ] |
Ken Fyten
made changes -
Assignee Priority | P1 | P2 |
Assignee | Philip Breau [ philip.breau ] | Patrick Corless [ patrick.corless ] |
Philip Breau
made changes -
Status | Open [ 1 ] | Resolved [ 5 ] |
Resolution | Invalid [ 6 ] |
Philip Breau
made changes -
Status | Resolved [ 5 ] | Closed [ 6 ] |
Adjusting priorities and assigning to Ken for re-assignment.