This post originated from an RSS feed registered with Java Buzz
by Joe Shelby.
Original Post: Tomcat 4 Servlet/JSP Classloading Hell
Feed Title: Joe's Java Jottings
Feed URL: http://www.blog-city.com/bc/
Feed Description: Notes, observations, and occasional other stuff on Java, with concentrations on Swing, XML, and the Semantic (Object) Web.
interface I class X implements I jsp Y creates instance of class X jsp Y does request.setAttribute("someI", X); jsp Y has custom taglibs
custom taglib tag Z (referenced in jsp Y) has code I theI = (I) request.getAttribute("someI");
ClassCastException ensues. in spite of everything I try, the "I" class definition in the custom taglib is loaded by a different classloader from the JSP that instantiated the object, so X is not an instanceof I when the taglib java code sees it.
why?
what is the point of making taglibs that can (should) be used to render special objects if you can't cast a reference to that object (or more importantly, an interface that object might implement)?