Return-Path: Delivered-To: apmail-ant-user-archive@www.apache.org Received: (qmail 17876 invoked from network); 22 Nov 2007 04:46:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Nov 2007 04:46:13 -0000 Received: (qmail 84834 invoked by uid 500); 22 Nov 2007 04:45:57 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 84806 invoked by uid 500); 22 Nov 2007 04:45:57 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 63220 invoked by uid 99); 21 Nov 2007 23:25:40 -0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of SRS0=Wb3V=QO=noacks.net=rainer@srs.kundenserver.de designates 212.227.126.186 as permitted sender) Reply-To: From: "Rainer Noack" To: "'Ant Users List'" References: <1d9506610711201245s442cac12v9d9b47a104135350@mail.gmail.com> <60f6b5090711202043k2bc7f2bfx6285c4b785f2c11e@mail.gmail.com> <1d9506610711210837j71fc79b6k851d1faa9b777d42@mail.gmail.com> <1d9506610711211233rb0aaa2td6d465b41e415182@mail.gmail.com> <1d9506610711211426u4752376fub9058366bc08fcd1@mail.gmail.com> Subject: AW: How do I set a classpath for my custom task? Date: Thu, 22 Nov 2007 00:25:20 +0100 Message-ID: <008001c82c95$c954db70$0601a8c0@ENITSYSMOB000R> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Office Outlook 11 Thread-Index: AcgsjZ3URjO7LKu3QIaa9E8NaZ4wfQABUhqw X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 In-Reply-To: <1d9506610711211426u4752376fub9058366bc08fcd1@mail.gmail.com> X-Provags-ID: V01U2FsdGVkX19AxgoXkFqKDSFcojYiPtOWir+yzVwUy6bgsR5 rWQsrnZW/27DmvMYMoq0oUzFskcaLsYa53kI84N22DxwQbrUOZ NTiP3/nlzU/o1bRfi9AGTTn7Uoetg6x X-Virus-Checked: Checked by ClamAV on apache.org Hi Todd, the problem is your call to Class.forName(String) in ...Engine. This uses Engine's Classloader. There are the following ways to add user-defined classes: 1. let the user add them to the classpath of the task's classloader or a = one of it's parents by 1.1. specify them in 's classpath-attribute of the migrate-task = or 1.2. add them via something like the task (see http://enitsys.sourceforge.net/ant-classloadertask/) or (IMHO better) 2. refactor the Engine class: All methods that use Class.forName(String) should get an parameter "ClassLoader classloader" and you should use Class.forName(String,boolean,ClassLoader) instead. The methods with the "old" signature should be redirected to the new = methods with classloader=3DEngine.class.getClassLoader(). In your task you have to create a new Classloader: if cp is your resolved classpathref, use new AntClassLoader(getClass().getClassLoader(),getProject(),cp) to construct = the new classpath. cheers Rainer Noack -----Urspr=FCngliche Nachricht----- Von: todd runstein [mailto:toddrun@gmail.com]=20 Gesendet: Mittwoch, 21. November 2007 23:26 An: Ant Users List Betreff: Re: How do I set a classpath for my custom task? The project is non platform specific, so it can run in a container, in a swing app, or from the command line. The project applies schema changes to a database. The user creates a class that implements a single interface, adding code that the project uses to apply the changes. I've currently got this working from the command line and in a servlet (in it's init method). I really want to create a simple to use ant task so schema changes can be applied prior to deployment, test runs, or whatever, but I can't get this classloader thing figured out. Not sure if it's helpful, but if you need more specifics about what I'm trying to do, the project is on sourceforge under the name migrate4j. If there's more info that I can provide, just let me know. Todd On Nov 21, 2007 1:40 PM, Martin Gainty wrote: > > Hi Todd-Could you provide a bit more contextWill you be implementing = this (web)application under J2EE server -or- perhaps a container such as = Catalina or Jetty?Generally these environments support their own classloader = loading algorithms depending on the capability and security characteristics of = the (web)application you will be implementing and which J2EE server and container will be the implementor-Martin --=20 ---------------------------------------------------------------------- The only "dumb question" is the one you were too afraid to ask. ________________________________________ Check out RouteRuler - Free software for runners, cyclists, walkers, = etc. http://routeruler.sourceforge.net ________________________________________ --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org