Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 17660 invoked from network); 20 Jun 2005 23:12:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Jun 2005 23:12:15 -0000 Received: (qmail 45954 invoked by uid 500); 20 Jun 2005 23:12:13 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 45903 invoked by uid 500); 20 Jun 2005 23:12:12 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 76997 invoked by uid 99); 20 Jun 2005 17:03:10 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: ant tasks creation of classloaders Date: Mon, 20 Jun 2005 10:03:03 -0700 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: ant tasks creation of classloaders Thread-Index: AcV0T0XKLsNn5forRTy4dpS0aKQPAgBaq2YQ From: "Hyke, Lea" To: "Ant Developers List" X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Please unsubscribe the jobs@netsuite.com from your list. -----Original Message----- From: Max Rydahl Andersen [mailto:max.andersen@jboss.com]=20 Sent: Saturday, June 18, 2005 2:44 PM To: dev@ant.apache.org Subject: ant tasks creation of classloaders Hi guys, Having some "fun" issues with classloading these days. I have a task (HibernateTool) that is used like this: Notice that the classpath of the taskdef and hibernatetool have no =20 overlaps. Until today I had the following code in the HibernateToolTask for creating =20 the classloader: AntClassLoader loader =3D getProject().createClassLoader(classPath); loader.setParent(getProject().getCoreLoader()); loader.setThreadContextLoader(); But when I run this stuff with the task above I get ClassNotFoundErrors for annotations defined in hibernate. This occurs because with the above classloader setup I effectively goes around the classpath - it will instead first look in the parent of the AntClassLoader I created and =20 this will be the system classloader which of course know nothing about the hibernate specific classloaders. Know my current work around for this is to do: AntClassLoader loader =3D getProject().createClassLoader(classPath); loader.setParent(this.getClass().getClassLoader()); <-- this is the =20 HibernateToolTask instance loader.setThreadContextLoader(); This will setup the right classloading sequence. But i'm just curious of why this does not seem to be the default way of doing things in the existing ant tasks ? e.g. in LoadProperties is: ClassLoader cL =3D (classpath !=3D null) ? getProject().createClassLoader(classpath) : LoadProperties.class.getClassLoader(); which for me says "ignore LoadProperties own classloader if i have a =20 " and most other places they *only* uses the core task loader which for me seems kinda strange (as it can give funny sideeffects if not all classes used by the isn't loaded yet) So, am I missing some crucial insight or is it just "random" how the =20 current ant tasks setup their classloaders :) ? Anyone which can think up any bad things with the classloader setup I did =20 here ? /max --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org