Reputation: 920
im trying to get the primefaces bar chart to work however i am getting the following error :
java.lang.ClassCastException: java.util.Vector cannot be cast to org.primefaces.model.chart.CartesianChartModel
WARNING: StandardWrapperValve[Faces Servlet]: Servlet.service() for servlet Faces Servlet threw exception
java.lang.ClassCastException: java.util.Vector cannot be cast to org.primefaces.model.chart.CartesianChartModel
at org.primefaces.component.chart.bar.BarChartRenderer.encodeData(BarChartRenderer.java:127)
at org.primefaces.component.chart.bar.BarChartRenderer.encodeScript(BarChartRenderer.java:51)
at org.primefaces.component.chart.bar.BarChartRenderer.encodeEnd(BarChartRenderer.java:36)
here is the code:
<p:barChart id="basic" value="#{markingBean.studentsMarks}" legendPosition="ne"
title="Basic Bar Chart" min="0" max="200" style="height:300px"/>
the studentsMarks is retrieved from a backing bean that does a db query
studentsMarks = markingFacade.getMarksForStudent(markToEdit);
and the db query to get the 13 marks i need :
public List getMarksForStudent(Marking id) {
System.out.println("In getMarksForStudent");
System.out.println("id = " + id);
System.out.println("id = " + id.getId());
Query m = em.createQuery("SELECT m.markSectionOne, m.markSectionTwo, m.markSectionThree, m.markSectionFour, m.markSectionFive, m.markSectionSix, m.markSectionSeven, m.markSectionEight, m.markSectionNine, m.markSectionTen, m.markSectionEleven, m.markSectionTwelve, m.markSectionThirteen FROM MARKING m WHERE m.id = :id", Double.class);
m.setParameter("id", id.getId()); // Note the getId()
System.out.println(m);
return m.getResultList();
}
what is causing the error and how can i fix it ?
Thanks guys :)
Upvotes: 0
Views: 1614
Reputation: 4189
Thank for clear question!
<p:barChart
require org.primefaces.model.chart.CartesianChartModel
value. You assign List
type, so jvm will show java.lang.ClassCastException
exception.
See the link below, and follow it:
Upvotes: 1