[jdom-interest] ClassCastException

Stephan Trebels stephan at ncube.de
Tue Sep 10 08:51:43 PDT 2002


This is my understanding of the problem as you describe it:

The situation is a simple custom classloader problem.  junit sandboxes
the test, which means, that the same class that was previously loaded
is no longer assignment compatible.  The same could happen for JSPs or
anyone who uses classloaders to control a sandbox environment.

If you get rid of the junit classloader, you should be fine.  If you
make sure no XML is loaded or _all_ XML classes are loaded when you
run junit's classloader, you should be fine as well.

What you have now is a mixture of classes from the correct
hierarchies, but from different classloaders, which is not assignment
compatible by JVM definition.

Stephan

On Tue, Sep 10, 2002 at 11:10:01AM -0400, kenk at boxerlearning.com wrote:
> > At 10:48 AM -0400 9/10/02, kenk at boxerlearning.com wrote:
> > 
> > >What I'd like to know is:
> > >
> > >1) Has this been officially reported as a bug in JDOM?
> > >2) Does anyone know of any plans to address the problem?
> > >3) Has anyone contacted the junit people about this bug?  It seems to me like
> > >it's a bug in junit, as well.
> > >
> > 
> > This is neither a bug in JDOM nor a bug in JUnit. It is arguably a 
> > bug in your code; but really what it really is is a bug in the design 
> > of Java's class loading mechanism. There's not a whole hell of a lot 
> > either JDOM or JUnit can do about this. Sorry :-(
> 
> How is it a bug in my code?  Is there a way I can write code so that I could 
> get this to work?  I see that JDOM.SAXBuilder has constructors where I can 
> specify the saxDriverClass.  Could using one of those solve this problem?
> 
> 
> > -- 
> > 
> > +-----------------------+------------------------+-------------------+
> > | Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
> > +-----------------------+------------------------+-------------------+
> > |          XML in a  Nutshell, 2nd Edition (O'Reilly, 2002)          |
> > |              http://www.cafeconleche.org/books/xian2/              |
> > |  http://www.amazon.com/exec/obidos/ISBN%3D0596002920/cafeaulaitA/  |
> > +----------------------------------+---------------------------------+
> > |  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      |
> > |  Read Cafe con Leche for XML News: http://www.cafeconleche.org/    |
> > +----------------------------------+---------------------------------+
> 
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

-- 
[------------ Stephan Trebels <stephan at ncube.de>, Consultant -----------]
company: nCUBE Deutschland GmbH, Hanauer Str. 56, 80992 Munich, Germany
phone: cell:+49 172 8433111  office:+49 89 149893 0  fax:+49 89 149893 50



More information about the jdom-interest mailing list