From user-return-73538-archive-asf-public=cust-asf.ponee.io@ant.apache.org Wed Feb 20 20:23:01 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id AF1C018075F for ; Wed, 20 Feb 2019 21:23:00 +0100 (CET) Received: (qmail 15362 invoked by uid 500); 20 Feb 2019 20:22:59 -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 15345 invoked by uid 99); 20 Feb 2019 20:22:58 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Feb 2019 20:22:58 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 711DAC1E8D for ; Wed, 20 Feb 2019 20:22:58 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.011 X-Spam-Level: *** X-Spam-Status: No, score=3.011 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=2, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_NONE=-0.0001, T_KAM_HTML_FONT_INVALID=0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id mAJYxmsKzBSC for ; Wed, 20 Feb 2019 20:22:54 +0000 (UTC) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.24]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 8A355623FF for ; Wed, 20 Feb 2019 20:22:54 +0000 (UTC) Received: from JanmySN ([89.245.6.6]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MqrsF-1hQt4O3OE5-00mp9h for ; Wed, 20 Feb 2019 21:22:54 +0100 From: =?utf-8?Q?Jan_Mat=C3=A8rne_=28jhm=29?= To: "'Ant Users List'" References: <02645207-e0ee-69e9-65db-5fb7c3f38287@bellsouth.net> <29875175-fcfc-23a1-ef1e-74734ab915aa@bellsouth.net> <0e209819-4ca4-0228-81d4-9f4960d8c1e8@bellsouth.net> <00751316-14b2-413c-335b-2b96fbb3ab8f@apache.org> <3d120ae0-ab3f-08d8-a772-ac25ff4863c8@bellsouth.net> In-Reply-To: <3d120ae0-ab3f-08d8-a772-ac25ff4863c8@bellsouth.net> Subject: AW: Javac Run By Ant Script is Unable to Find External Jars Date: Wed, 20 Feb 2019 21:22:45 +0100 Message-ID: <002301d4c95a$0a7b2830$1f717890$@de> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0024_01D4C962.6C3F9030" X-Mailer: Microsoft Office Outlook 12.0 Content-Language: de Thread-Index: AdTIYRRiVTpG1wRnSTeGYVW2E/RC9AA99l2w X-Provags-ID: V03:K1:kam23bSBpP9pKpKL4kC5r26J4TNHsopoOBw5jKNFU8WSTvTyPL5 Osrkh7vKBVJtM1g2d+GNTIvoOR5BkpgPIJY2vdBrpnZeoDFDLh6B4WaNos8nfwgpFrssnLY UnjSSNB5CrNvBKI3BEUzyRsQQ0yPCGXfD5ScU0mmROHlYSRB5RlPtAUe7IrBqR0494CZ083 NFtn2hA7fDCKKu8nhKctQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:WUsymyaTVl0=:3W8yy1Ccnynqf+7m6NU2Gu aNwumOf1fFWkcnEM7aIFT2AD0o7aODvCDm6JPqyYOa1KGeOyAX5YhhU+ZaUUgZDVKxBeqREAs W7BiYIyEEknj+0650l+PMhqcXA+MqmBxbKcOW14jANpPCpQ66TnnUOOHuZjy9UhyOZQLf5onO XWY2YzFGZHobqVOPyKgdYrH8zk0kulUOKw7OstkdxLFNqJQ38Ju+0HdZKdUeGJA5h9R4oanK1 7OfDLac4g4jcuiFtQkmrX7b0fzDP3iMa2Pj0fFH/IRsEfrS60Awu3ehLmRa0zky48vyJ4nutv j6Qcz5JhIEYEkOokXLGAc4d70389l7oP3uRWqv8HKdn4x8XiyeTcGQPb1Wi8LfrqWVnxDneOk yiz7ViVmGf6anPY6nyX1jsbc8uwnoLeaJBAgm7CBFOLJFDk7Q2FlzxuFDd1vWoufzX1bMwszF rrjvmjmtHHynUZpxbwB0LpEKKqkoS65n6z5o+dIcQn90VFIJhcz2hFXT88pY7ivmQLDKQnvE/ jyK5YBwANJ9izVP4tk841u0swm6TSmmhlxVue3UVl6CewkzVza5MXg3nZCKYIdcrmOoKyMRbR Ehz5yvNxDDn+4EREneMhYJa1zvoPUhjrCR1LHS9BqSadbtZJDuA4wfk7iIWbN8hPLa6NlXX2z /Ei9izTtxZIjqtpsutnkcTeYqDtOO7Iv///HE6bvtjYMvqM/YTmaNbhxYTFvSGXLxV5rnalPT PGwdPITXuORFGYYQKDXnByHjS/AlYC4rx9leqLp98tLVZeFkFn/ZKZEByMA= ------=_NextPart_000_0024_01D4C962.6C3F9030 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable If you have created your JAR the first step is done. Starting the JAR could be done in several ways. Common is that you have = to have all external classes on the runtime classpath: =20 1. Hard coded start script. Write a bash/bat-Script with the java command with all cp settings, e.g. = (bat) @echo off java -cp /build/myjar.jar;lib/one.jar;lib/two.jar;lib/three.jar = org.acme.Main %* =20 2. Wrapper script which collects all JARs in a dynamic way (see = ant.bat|ant.sh) =20 3. Use Ant + for starting =20 4. Create a runnable JAR which references the external JARs (manifest: = main-class + classpath) =20 5. Create a shaded jar (uber jar, fat jar): include all classes from = external jars into your jar =20 6. Use a launcher which uses a dependency manager for getting the = classpath =20 =20 =20 You don't have to replicate path definitions in your buildfile, you = could (and should) use references: =E2=80=A6 =20 =20 You mave have a look at = http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html =20 =20 Jan =20 =20 Von: Dennis Putnam [mailto:dap1@bellsouth.net]=20 Gesendet: Dienstag, 19. Februar 2019 15:40 An: user@ant.apache.org Betreff: Re: Javac Run By Ant Script is Unable to Find External Jars =20 Hi Jaikiran, Thanks for the reply. Here is my command: /bin/ant -v -Dmember.number=3D$number -Dmember.name=3D\"$name\" -f = makejar.xml I assume it is using ant's java task based on the build file = (makejar.xml). I'm a bit confused. Doesn't all the necessary classpath = info come from the build xml? Since the Maven pom.xml is never = referenced anywhere in the build file and the Maven dependency causes = that exception, it seems to me that is where the problem lies. Doesn't = the pom.xml need to be referenced somewhere? In any case, how do I set up a classpath for the ant command (-lib) = since I have multiple paths? Do I have to copy all my jars into a single = directory? Why is duplication of these paths even necessary? This seems = like it is getting far afield since I did not have to do all that before = I messed up the build file classpath. On 2/18/2019 11:03 PM, Jaikiran Pai wrote: Hi Dennis, =20 I think you are almost there to get this working. How are you running this Java application? Are you using Ant's java task? What does it look like? Just like you did with javac, the java task will need to know what classpath to use while running the application. As long as you setup your classpath to contain all these necessary jar files, you should no longer see those exceptions. =20 -Jaikiran =20 On 18/02/19 8:15 PM, Dennis Putnam wrote: Hi Matt and Jan, =20 Thanks to both of you as I am closer but I think I am still missing a piece. I am now getting a successful build but the resulting jar is not finding the classes in the external jars. When I run the jar I get this exception: =20 Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/HttpEntity at KCBSEvents.Registration.isRegistered(Unknown Source) at KCBSEvents.KCBSEvents.main(Unknown Source) Caused by: java.lang.ClassNotFoundException: org.apache.http.HttpEntity at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown = Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 2 more =20 =20 That happens to be the first attempt to execute one of the external jar classes which is a Maven dependency. Here is my new build.xml: =20 *** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** * ** =20 Does this come back to my question about needing the zipfileset elements for the Maven jars? I don't know how the pom.xml for Maven gets pulled into this either. =20 On 2/17/2019 12:45 PM, Matt Bertolini wrote: Hi Dennis, =20 I think you might be mixing up Eclipse concepts and Ant concepts and = that might be causing some extra confusion. Based on your original email, the compiler is having issues finding your third-party dependencies. I = believe Jaikiran is correct in saying that the task needs to be given = some sort of classpath. The .classpath file is an Eclipse concept and unless there is some sort of Eclipse/Ant plugin I am not aware of, the = .classpath file will have no effect on Ant=E2=80=99s, task. Also, I = don=E2=80=99t believe the task has a default value for the classpath attribute. If no classpath or classpathref is specified then the compiler is not passed = any classpath information. =20 I would start by locating the folder where your third-party dependencies are and create a element containing them like this: =20 =20 Once you have a path defined you can pass the classpath to the = task using a refid like this: =20 =20 Try that and see how it goes. =20 Matt Bertolini =20 =20 =20 =20 =20 ------=_NextPart_000_0024_01D4C962.6C3F9030--