Bug 33117 - ClassCastException with tasks using Xerces
Summary: ClassCastException with tasks using Xerces
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Ant (show other bugs)
Version: 2.1   Edit
Hardware: PC All
: P2 major (vote)
Target Milestone: 2.1 RC2   Edit
Assignee: Jared Burns CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 33447 33650 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-02-25 15:45 EST by Pascal Rapicault CLA
Modified: 2003-03-03 16:04 EST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pascal Rapicault CLA 2003-02-25 15:45:26 EST
I have a task that uses xerces and when it tries to load a xerces class, a 
ClassCastException is thrown. 

After tracking down the problem, it appears that two versions of xerces are in 
memory:
  1 - the one that my tasks uses (it got loaded through the regular plugin 
loader hierarchy)
  2 - the one that the antLoader is using. To be precise, the xerces classes 
are loaded in the antLoader because it is not chained to the xerces plugin 
classloader and simply refers to the jars (see 
AntCorePreferences::getDefaultAntURLs). 

To avoid this problem, instead of referencing directly jars you should 
reference the classloader that olds on to these jars.

If I was not clear, don't hesitate to contact me.

Note that this was working fine before the fix for bug #21793 has been put in, 
because xerces is using the contextClassLoader to load its classes.
Comment 1 Darin Swanson CLA 2003-02-25 15:58:41 EST
I agree. 
Since org.eclipse.ant.core requires the org.apache.xerces plugin it should set 
that plugin classloader to be a parent plugin classloader instead of adding the 
URLs for the xerces JARs to the AntClassloader classpath. 
In fact, this would just work if we remove the xerces JARs. The plugin 
classloader for the org.eclipse.ant.core is already added as a plugin 
classloader.
Comment 2 Darin Swanson CLA 2003-02-28 11:40:31 EST
Fixed in AntCorePreferences.
Please verify (Jared).
Comment 3 Jared Burns CLA 2003-02-28 16:02:06 EST
Verified code. Pascal, can you please verify that your test case works
correctly now?
Comment 4 DJ Houghton CLA 2003-03-03 09:59:13 EST
*** Bug 33650 has been marked as a duplicate of this bug. ***
Comment 5 Darin Swanson CLA 2003-03-03 11:23:05 EST
*** Bug 33447 has been marked as a duplicate of this bug. ***
Comment 6 Pascal Rapicault CLA 2003-03-03 12:47:31 EST
I checked on a windows machine with the code from HEAD.
It works.
I'll do a test on a linux box later in the afternoon.