0

i deploy my project in tomcat7 ,and when starting my jsf ,i've a problem of casting .when i delete binding="#{courseBean.courseTable}" i got my table ,but it's empty . i followed a tutorial step by step ,but i don't know where is the problem .

org.apache.jasper.JasperException: An exception occurred processing JSP page /courselist.jsp at line 20

17:     <h:form id="mainForm">
18: 
19:         <h:panelGrid columns="1">
20:             <rich:scrollableDataTable id="courseTable"
21:                 binding="#{courseBean.courseTable}" value="#{courseBean.courseList}"
22:                 var="course" width="300px" height="200px">
23:                 <%-- <a4j:support event="onRowDblClick" <%-- action="#{courseBean.viewDetail}" --%> /> --%>


Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:537)
    com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:275)
    com.sun.faces.application.view.JspViewHandlingStrategy.renderView(JspViewHandlingStrategy.java:118)
    com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:152)
    org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
    org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:189)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:97)
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:102)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:311)
    org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:147)
    org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276)
    org.ajax4jsf.Filter.doFilter(Filter.java:175)


cause mère 

javax.faces.FacesException: java.lang.ClassCastException: java.lang.String cannot be cast to javax.faces.component.UIComponent
    com.sun.faces.application.ApplicationImpl.createComponentApplyAnnotations(ApplicationImpl.java:1694)
    com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:429)
    javax.faces.webapp.UIComponentELTag.createComponent(UIComponentELTag.java:222)
    javax.faces.webapp.UIComponentClassicTagBase.createChild(UIComponentClassicTagBase.java:486)
    javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassicTagBase.java:670)
    javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTagBase.java:1142)
    org.apache.jsp.courselist_jsp._jspx_meth_rich_005fscrollableDataTable_005f0(courselist_jsp.java:271)
    org.apache.jsp.courselist_jsp._jspx_meth_h_005fpanelGrid_005f0(courselist_jsp.java:225)
    org.apache.jsp.courselist_jsp._jspx_meth_h_005fform_005f0(courselist_jsp.java:181)
    org.apache.jsp.courselist_jsp._jspx_meth_f_005fview_005f0(courselist_jsp.java:136)
    org.apache.jsp.courselist_jsp._jspService(courselist_jsp.java:98)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:537)
    com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:275)
    com.sun.faces.application.view.JspViewHandlingStrategy.renderView(JspViewHandlingStrategy.java:118)
    com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:152)
    org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
    org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:189)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:97)
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:102)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:311)
    org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:147)
    org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276)
    org.ajax4jsf.Filter.doFilter(Filter.java:175)


cause mère 

java.lang.ClassCastException: java.lang.String cannot be cast to javax.faces.component.UIComponent
    com.sun.faces.application.ApplicationImpl.createComponentApplyAnnotations(ApplicationImpl.java:1683)
    com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:429)
    javax.faces.webapp.UIComponentELTag.createComponent(UIComponentELTag.java:222)
    javax.faces.webapp.UIComponentClassicTagBase.createChild(UIComponentClassicTagBase.java:486)
    javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassicTagBase.java:670)
    javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTagBase.java:1142)
    org.apache.jsp.courselist_jsp._jspx_meth_rich_005fscrollableDataTable_005f0(courselist_jsp.java:271)
    org.apache.jsp.courselist_jsp._jspx_meth_h_005fpanelGrid_005f0(courselist_jsp.java:225)
    org.apache.jsp.courselist_jsp._jspx_meth_h_005fform_005f0(courselist_jsp.java:181)
    org.apache.jsp.courselist_jsp._jspx_meth_f_005fview_005f0(courselist_jsp.java:136)
    org.apache.jsp.courselist_jsp._jspService(courselist_jsp.java:98)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:537)
    com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:275)
    com.sun.faces.application.view.JspViewHandlingStrategy.renderView(JspViewHandlingStrategy.java:118)
    com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:152)
    org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
    org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:189)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:97)
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:102)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:311)
    org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:147)
    org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276)
    org.ajax4jsf.Filter.doFilter(Filter.java:175)

courselist.jsf :

<rich:scrollableDataTable id="courseTable"
                binding="#{courseBean.courseTable}" value="#{courseBean.courseList}"
                var="course" width="300px" height="200px">
                <%-- <a4j:support event="onRowDblClick" <%-- action="#{courseBean.viewDetail}" --%> /> --%>
                <rich:column id="code" width="60px">
                    <f:facet name="header">
                        <h:outputText value="Code" />
                    </f:facet>
                    <h:outputText value="#{course.code}" />
                </rich:column>
                <rich:column id="name" width="200px">
                    <f:facet name="header">
                        <h:outputText value="Nom" />
                    </f:facet>
                    <h:outputText value="#{course.name}" />
                </rich:column>
                <rich:column id="length" width="60px">
                    <f:facet name="header">
                        <h:outputText value="Longueur" />
                    </f:facet>
                    <h:outputText value="#{course.length}" />
                </rich:column>

            </rich:scrollableDataTable>

coursebean.java

public class CourseBean implements Serializable {

    @Autowired
    private transient courseService courseService;
    private transient HtmlScrollableDataTable courseTable;

    private List<Course> courseList;
    private Course currentCourse;

    @PostConstruct
    public void init() {
        courseList = courseService.findAll();
    }


    public String update() {
        courseService.save(currentCourse);
        init();
        return null;
    }

    public HtmlScrollableDataTable getCourseTable() {
        return courseTable;
    }

    public void setCourseTable(HtmlScrollableDataTable courseTable) {
        this.courseTable = courseTable;
    }

    public List<Course> getCourseList() {
        return courseList;
    }

    public void setCourseList(List<Course> courseList) {
        this.courseList = courseList;
    }

    public Course getCurrentCourse() {
        return currentCourse;
    }

    public void setCurrentCourse(Course currentCourse) {
        this.currentCourse = currentCourse;
    }

}
Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
Ziko
  • 135
  • 1
  • 4
  • 10
  • now i work in a project and i'm blocked now . so if someone can help i'll be thankful . – Ziko Aug 04 '12 at 13:56
  • Try changing the id of your scrollableDataTable. – Luiggi Mendoza Aug 04 '12 at 18:35
  • i cahnged it ,but i've always the same error. – Ziko Aug 04 '12 at 22:03
  • Are you using JSF 2 and RF 3.3.3 or JSF 1.2? – Luiggi Mendoza Aug 04 '12 at 22:12
  • Try replacing the `` for `` and don't use the binding and check that your list is not null and is not empty. In case your list is null or empty, use the @KeepAlive tag to your bean (only if your bean is request scoped). Also, it will be better to upgrade to [RichFaces 3.3.3 Final](http://www.jboss.org/richfaces/download/stable). – Luiggi Mendoza Aug 05 '12 at 01:16
  • 1.2? Really? The stacktrace suggests 2.x. The whole `com.sun.faces.application.view` package doesn't exist in Mojarra 1.2 at all. It was introduced in Mojarra 2.0. Or do you mean that you're running Mojarra 2.x in JSF 1.2 modus by declaring the `faces-config.xml` conform JSF 1.2 spec? – BalusC Aug 05 '12 at 02:19
  • @LuiggiMendoza my list is null . i don't know how to use KeepAlive tag to my bean. – Ziko Aug 05 '12 at 13:38
  • @BalusC ,yeah i mean that i am running Mojarra 2.x in JSF 1.2 modus by declaring the faces-config.xml conform JSF 1.2. – Ziko Aug 05 '12 at 13:41
  • i made some changes in my JSF ,and i don't see anymore these errors : .but i got an empty list ,because i think that i have a problem in my application-contex.xml ( my coursebean.java is not well declared ) !!! – Ziko Aug 06 '12 at 23:04

0 Answers0