Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 30204 invoked from network); 27 Sep 2005 12:50:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 27 Sep 2005 12:50:20 -0000 Received: (qmail 51803 invoked by uid 500); 27 Sep 2005 12:50:18 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 51747 invoked by uid 500); 27 Sep 2005 12:50:17 -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 51734 invoked by uid 99); 27 Sep 2005 12:50:17 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Sep 2005 05:50:17 -0700 X-ASF-Spam-Status: No, hits=4.8 required=10.0 tests=DNS_FROM_RFC_ABUSE,DNS_FROM_RFC_POST,FORGED_MUA_OUTLOOK,MSGID_FROM_MTA_HEADER,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of mgainty@hotmail.com designates 65.54.174.90 as permitted sender) Received: from [65.54.174.90] (HELO hotmail.com) (65.54.174.90) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Sep 2005 05:50:21 -0700 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Tue, 27 Sep 2005 05:49:53 -0700 Message-ID: Received: from 65.54.174.208 by BAY103-DAV18.phx.gbl with DAV; Tue, 27 Sep 2005 12:49:52 +0000 X-Originating-IP: [65.54.174.208] X-Originating-Email: [mgainty@hotmail.com] X-Sender: mgainty@hotmail.com Reply-To: "Martin Gainty" From: "Martin Gainty" To: Cc: "Ant Developers List" References: <4338F909.1020705@clear2pay.com> Subject: Re: NoClassDefFoundError when loading class from -lib Date: Tue, 27 Sep 2005 08:49:50 -0400 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-OriginalArrivalTime: 27 Sep 2005 12:49:53.0295 (UTC) FILETIME=[F49AB1F0:01C5C361] X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Jon- Follow the log4j Install doc at http://www.ingrid.org/jajakarta/log4j/jakarta-log4j-1.1.3/INSTALL Marty- "Life is what happens when you're busy making other plans" - John Lennon ----- Original Message ----- From: "Jon McLennan" To: Sent: Tuesday, September 27, 2005 3:47 AM Subject: NoClassDefFoundError when loading class from -lib >I posted this to the users list, but didn't get any response. Maybe > someone on this list can help. > > I've taken the source for org.apache.tools.ant.Launcher and modified it > to call my own version of Main.java. Essentially, the only change I made > with that class is to allow the user to specify which startup class is > to be run. (The default is the standard org.apache.tools.ant.Main.) My > version of Main can create menus from targets in the build file (plus > some other features). I use log4j for logging debugging messages. > > The problem I'm running into is when I call this line: > > Class mainClass = Class.forName(classmain, false, loader); > // classmain = my Main.java > > I get this error: > > java.lang.NoClassDefFoundError: org/apache/log4j/Category > at java.lang.Class.newInstance0(Native Method) > at java.lang.Class.newInstance(Class.java:232) > at com.clear2pay.releng.Launcher.run(Launcher.java:351) > at com.clear2pay.releng.Launcher.main(Launcher.java:75) > > I'm running Ant 1.6.1 (installed at D:\java\ant-1.6.1) and my external > lib directory (D:\java\lib) is passed to Ant via the -lib command line > arg. I have log4j-1.2.6.jar in that directory. > > This is the command line I use: > > java !ANT_OPTS! -classpath > "d:\java\lib\releng.jar; > d:\java\apache-ant-1.6.1\lib\ant.jar; > d:\java\apache-ant-1.6.1\lib\ant-launcher.jar; > d:\java\apache-ant-1.6.1\lib\xml-apis.jar; > d:\bea\jdk131\jre\lib\rt.jar; > d:\bea\jdk131\lib\dt.jar; > d:\bea\jdk131\lib\tools.jar; > d:\bea\jdk131\jre\lib\i18n.jar;" com.clear2pay.releng.Launcher > -lib "D:\java\lib" > -mc com.clear2pay.releng.Main > > > I put some debugging statements in com.clear2pay.releng.Launcher to see > if org.apache.log4j.Category has been loaded by the ClassLoader > > Class myClass = loader.loadClass("org.apache.log4j.Category"); > System.out.println("myClass = " + myClass); > > which outputs: > > myClass = class org.apache.log4j.Category > > I even tested it by listing the methods available from that class. > > So what I don't understand is, why is com.clear2pay.releng.Launcher able > to find org.apache.log4j.Category when I get it from the loader, but it > can't be found when I load a class that imports it? I can get this to > work if I put all external jars I need directly in the Classpath, but > this can cause problems on Windows if the value of Classpath gets too > long and I'd like to avoid that. > > Jon > > > --------------------------------------------------------------------- > 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