Hello my name is Claudio Veas Im very new in tomcat develop and I was trying to use an interface to implement a cache. I make all the objects that I wanted to keep in memory implement "cacheable" interface so I could insert them into a Vector and then minimize the timing when looking for the same information. I dont have problems storing information in cache, and I dont have problems when I try to retrieve directly to a variable declared "cacheable" but when I try a direct cast the server shows me this error
type Informe de Excepción mensaje descripción El servidor encontró un error interno () que hizo que no pudiera rellenar este requerimiento. excepción org.apache.jasper.JasperException: materias.materias org.apache.jasper.servlet.JspServletWrapper handleJspException(JspServletWrapper.java:510) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper java:393) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) causa raíz java.lang.ClassCastException: materias.materias materia.experto_materias.getmaterias(experto_materias.java:54) org.apache.jsp.buscatema_jsp._jspService(buscatema_jsp.java:88) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper java:332) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) nota La traza completa de la causa de este error se encuentra en los archivos de diario de Apache Tomcat/5.5.16. Here are the interface and the classes CACHEABLE package interfaz_dbms; public interface cacheable { public int getId(); public int getTipo(); } CACHE (some cache procedures ) public void agregar(cacheable obj){ Enumeration e=memoria.elements(); while(e.hasMoreElements()){ cacheable temp = (cacheable) e.nextElement(); if(obj.getId()==temp.getId()||obj.getTipo()==temp.getTipo()){ return; } } memoria.addElement(obj); } MATERIAS (this procedures gets all the "materias" (subjects) that a profesor teaches, and i saves it in the cache object) public static Vector getMateriaProf(int id){ Vector v=new Vector(); try{ String consulta ="SELECT m.id_materia,m.nombre,m.descripcion " + " FROM materia m, mat_profe mp, profesor p " + " WHERE m.id_materia = mp.id_materia " + " AND p.id_profesor = mp.id_profesor " + " AND p.id_profesor=" + String.valueOf(id); ResultSet rs = conneccion.getconection().Consultar(consulta); rs.next(); while(!(rs.isAfterLast())){ materias m=new materias(rs.getInt("id_materia"),rs.getString( nombre"),rs.getString("descripcion")); v.addElement(m); if(cache.getReferencia().EstaEn(m)==null){ cache.getReferencia().agregar(m); } rs.next(); } } catch(SQLException e){ } return v; } EXPERTO MATERIAS (in some other page I request one of the "materias" but before going to the database again I search for it in memory I retrieved into a cacheable object and when I try the casting the error show up ) public materias getmaterias(int id){ materias n = new materias(); interfaz_dbms.cacheable temp; temp = interfaz_dbms.cache.getReferencia().Buscar(id,n.getTipo()); n = (materia.materias)temp; if(temp==null){ n = materias.consultar(id); } return n; } I really hope I ve been clear enough and I hope you can help me out with this problems. Please excuse my english Im not very good at it Thanks on advance Claudio Veas