From user-return-64750-apmail-ant-user-archive=ant.apache.org@ant.apache.org Wed May 07 21:41:50 2008 Return-Path: Delivered-To: apmail-ant-user-archive@www.apache.org Received: (qmail 25448 invoked from network); 7 May 2008 21:41:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 May 2008 21:41:50 -0000 Received: (qmail 49937 invoked by uid 500); 7 May 2008 21:41:49 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 49907 invoked by uid 500); 7 May 2008 21:41:49 -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 49895 invoked by uid 99); 7 May 2008 21:41:49 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 May 2008 14:41:49 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of bozmoz@gmail.com designates 64.233.182.184 as permitted sender) Received: from [64.233.182.184] (HELO nf-out-0910.google.com) (64.233.182.184) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 May 2008 21:41:04 +0000 Received: by nf-out-0910.google.com with SMTP id g13so257892nfb.10 for ; Wed, 07 May 2008 14:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=djTot55kkW4OWJLdMaCaxUQQv/ghphlUmgGd1NZRNWM=; b=B728VwoJOzO0kMHOZnIC+uO14Z0z1zG17aJNYRZj52dON6TcjQgYP8eSc6pT39mA/bkwG0q9jejjfUO3nlAlr0KjxusmhN6x9axZ2tE5wWiCRD4MyZ711yhbqnnoruewyiGAKB2XFuVV+qnbnpi2OikrN5nTF56fcSli1bF6NMs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=KcMDX85tTFkX1iQtpy1jey/bczXxPY+1KDCsHVbDNphxtz+eQcYTBLQHIJ3aLwHlI9iGAjEMEHrSHGPQm40SIzF72bXCsUQk6Hyb7nRpFAI5K8oB3ynvz+I9VyMJ3/iVTq9H+Xrn8kz1HmNl047ACYfoJs1InmzW8DrsveIwx3U= Received: by 10.78.198.14 with SMTP id v14mr716051huf.115.1210196476569; Wed, 07 May 2008 14:41:16 -0700 (PDT) Received: by 10.78.194.12 with HTTP; Wed, 7 May 2008 14:41:16 -0700 (PDT) Message-ID: <85b06e5c0805071441g26833613y57418de5f899cb6b@mail.gmail.com> Date: Wed, 7 May 2008 14:41:16 -0700 From: "Christofer Jennings" To: "Ant Users List" Subject: Re: classloader problem? In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_27730_13029531.1210196476563" References: <85b06e5c0805041022i538cb44y6945f01747236a59@mail.gmail.com> <200805071500.m47F0H0R009132@ha-node-br2.hpl.hp.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_27730_13029531.1210196476563 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Ah ha! That was it! ... I was ... getProject().createClassLoader(classpath); ... when I needed to ... getProject().createClassLoader(MyAnnotation.class.getClassLoader();, classpath); THANKS Peter! On Wed, May 7, 2008 at 8:49 AM, Peter Reilly wrote: > Also remember to use the classloader that loaded the > custom task as the parent for the new classloader > created in the task. > > Peter > > On Wed, May 7, 2008 at 3:59 PM, Steve Loughran wrote: > > > > Christofer Jennings wrote: > > > > > I think I have a classloader problem. > > > > > > I've made a custom task that looks through classes for a method > > annotation, > > > then makes a report. I've got junit tests that work in my IDE showing > that > > > the annotations can be found. But when I run the task the annotations > are > > > not recognized. .... That is, the annotation is there. I can read its > > type. > > > But if I ask the method for an annotation matching the class it > doesn't > > > match. (Yes, the class matches the reported type.: e.g., > > > com.foo.MyAnnotation.class) > > > > > > So I think I have a classloader problem. My task accepts a path to > find > > the > > > classes with the annotations. It creates a classloader from the ant > > project, > > > passing in the given path. My theory is that the classes loaded by my > task > > > are on a different classloader than the MyAnnotation.class and that is > why > > > they don't match. ... Sound right? .... If so how do I get them on the > > same > > > classloader? > > > > > > > > > > I think that hypothesis sounds right, but don't know where to deal with > it. > > Can you load the tags you want to look for in the classloader that you > are > > loading the classes in? > > > > > > --------------------------------------------------------------------- > > 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 > > ------=_Part_27730_13029531.1210196476563--