This discussion is archived
2 Replies Latest reply: Jun 3, 2010 4:53 AM by EJP RSS

Getting Error --java.lang.ClassCastException:

843793 Newbie
Currently Being Moderated
Error That i got

java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to com.cybage.cybmon.model.MachineData


*public* List<MachineData> getData(*int* id)


{


String query="select MD.ramSize,MD.cpuTemp,MD.cpuType FROM MachineData MD where MD.srNo="+id;


List<MachineData> macDataList= _(List<MachineData>)sess.createQuery(query).list()_;


trans.commit();


*return* macDataList;




}


After that it rerturn to my servlet

*
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException

*

{





PrintWriter pw=response.getWriter();


int id=Integer.+parseInt+(request.getParameter("id"));


MapUserDataToDataBase macDataFromDB=*new* MapUserDataToDataBase();


List<MachineData> macDataList=macDataFromDB.getData(id);





MachineData macdata=(MachineData)macDataList.get(0);





pw.print("<table border=10><tr><th>RAM SIZE</th><th>Cpu Type</th><th>Cpu Temp </th></tr><br/>");


pw.println("<tr><td>"+macdata.getRamSize()+"</td>"+"<td>"+macdata.getCpuType()+"</td>"+"<td>"+macdata.getCpuTemp()+"</td></tr>");


pw.flush();





}



why it gives me the error