ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Keith Hatton" <khat...@axiomsystems.com>
Subject RE: Java task - jar woes but classname goes
Date Fri, 16 Jul 2004 07:58:29 GMT
Hi Geoff,

>From the JDK Tool docs:

java -jar ... "When you use this option, the JAR file is the source of all user classes, and
other user class path settings are ignored."

If you want to launch an application using java -jar, then build that jar file with a Class-Path
entry in its manifest.

Hope this helps
Keith


-----Original Message-----
From: Geoff Capper [mailto:geoffcapper@ozemail.com.au]
Sent: 16 July 2004 04:11
To: Ant Users List
Subject: Java task - jar woes but classname goes


Hi,

I'm not sure if I'm having a problem with my understanding of java or of 
ant at this stage (or maybe just understanding in general), and I hope 
that someone can point me in the right direction. My problem is as follows:

Background:
Ant: 1.6.1
Java: 1.4.2_04
In my build script I have "compile-app", "run-build" and  "run-app" 
tasks. I am using external jars from Hibernate, so for each of these 
tasks I specify a classpath, for "compile-app" it is simply the main 
Hibernate jar, for the other two it is a fileset of everything within my 
lib/ directory matching *.jar, which includes the main Hibernate jar.

Problem:
If I run "run-build" everything works fine.

If I run "run-app" with a "classname" attribute, having included the 
application jar in the classpath everything works fine.

If I run "run-app" with a "jar" attribute for the application jar 
(jarred using ant with a mainclass manifest element) I get a 
NoClassDefFoundError for one of the Hibernate classes.

I am running with the debug arg, and the output from ant says the jar is 
on the classpath. The classpath isn't changed when I use either 
jar/classname, so to my mind it seems I shouldn't have this problem.

I feel sure I have done something stupid, or misunderstood something 
somewhere, but I cannot figure out what. My apologies if this is the 
same as all the other classpath issues, but I seem to have exhausted all 
of the possibilities presented in other emails on that topic, such as 
duplicate jars etc.

I have included some of the debug stuff below.

Thanks for any help,
Geoff


Partial output of failed build:

run-app:
Executing 'C:\j2sdk1.4.2_04\jre\bin\java.exe' with arguments:
'-classpath'
'D:\prjAgraria\lib\Agraria.jar;D:\prjAgraria\lib\ext\ant-1.5.3.jar;D:\prjAgraria\lib\ext\ant-optional-1.5.3.jar;D:\prjAgraria\lib\ext\c3p0-0.8.4.5.jar;D:\prjAgraria\lib\ext\cglib-full-2.0.1.jar;D:\prjAgraria\lib\ext\commons-collections-2.1.jar;D:\prjAgraria\lib\ext\commons-dbcp-1.1.jar;D:\prjAgraria\lib\ext\commons-lang-1.0.1.jar;D:\prjAgraria\lib\ext\commons-logging-1.0.3.jar;D:\prjAgraria\lib\ext\commons-pool-1.1.jar;D:\prjAgraria\lib\ext\concurrent-1.3.2.jar;D:\prjAgraria\lib\ext\connector.jar;D:\prjAgraria\lib\ext\dom4j-1.4.jar;D:\prjAgraria\lib\ext\ehcache-0.7.jar;D:\prjAgraria\lib\ext\hibernate2.jar;D:\prjAgraria\lib\ext\hsqldb.jar;D:\prjAgraria\lib\ext\jaas.jar;D:\prjAgraria\lib\ext\jboss-cache.jar;D:\prjAgraria\lib\ext\jboss-common.jar;D:\prjAgraria\lib\ext\jboss-jmx.jar;D:\prjAgraria\lib\ext\jboss-system.jar;D:\prjAgraria\lib\ext\jcs-1.0-dev.jar;D:\prjAgraria\lib\ext\jdbc2_0-stdext.jar;D:\prjAgraria\lib\ext\jgroups-2.2.1.jar;D:\prjAgraria\lib\ext\jta.jar;D:\prjAgraria\lib\ext\junit-3.8.1.jar;D:\prjAgraria\lib\ext\log4j-1.2.8.jar;D:\prjAgraria\lib\ext\odmg-3.0.jar;D:\prjAgraria\lib\ext\oscache-2.0.jar;D:\prjAgraria\lib\ext\proxool-0.8.3.jar;D:\prjAgraria\lib\ext\swarmcache-1.0rc2.jar;D:\prjAgraria\lib\ext\xalan-2.4.0.jar;D:\prjAgraria\lib\ext\xerces-2.4.0.jar;D:\prjAgraria\lib\ext\xml-apis.jar'
'-jar'
'D:\prjAgraria\lib\Agraria.jar'

The ' characters around the executable and arguments are
not part of the command.
java.lang.NoClassDefFoundError: net/sf/hibernate/HibernateException
Exception in thread "main"

Partial output of successful build:

run-app:
Executing 'C:\j2sdk1.4.2_04\jre\bin\java.exe' with arguments:
'-classpath'
'D:\prjAgraria\lib\Agraria.jar;D:\prjAgraria\lib\ext\ant-1.5.3.jar;D:\prjAgraria\lib\ext\ant-optional-1.5.3.jar;D:\prjAgraria\lib\ext\c3p0-0.8.4.5.jar;D:\prjAgraria\lib\ext\cglib-full-2.0.1.jar;D:\prjAgraria\lib\ext\commons-collections-2.1.jar;D:\prjAgraria\lib\ext\commons-dbcp-1.1.jar;D:\prjAgraria\lib\ext\commons-lang-1.0.1.jar;D:\prjAgraria\lib\ext\commons-logging-1.0.3.jar;D:\prjAgraria\lib\ext\commons-pool-1.1.jar;D:\prjAgraria\lib\ext\concurrent-1.3.2.jar;D:\prjAgraria\lib\ext\connector.jar;D:\prjAgraria\lib\ext\dom4j-1.4.jar;D:\prjAgraria\lib\ext\ehcache-0.7.jar;D:\prjAgraria\lib\ext\hibernate2.jar;D:\prjAgraria\lib\ext\hsqldb.jar;D:\prjAgraria\lib\ext\jaas.jar;D:\prjAgraria\lib\ext\jboss-cache.jar;D:\prjAgraria\lib\ext\jboss-common.jar;D:\prjAgraria\lib\ext\jboss-jmx.jar;D:\prjAgraria\lib\ext\jboss-system.jar;D:\prjAgraria\lib\ext\jcs-1.0-dev.jar;D:\prjAgraria\lib\ext\jdbc2_0-stdext.jar;D:\prjAgraria\lib\ext\jgroups-2.2.1.jar;D:\prjAgraria\lib\ext\jta.jar;D:\prjAgraria\lib\ext\junit-3.8.1.jar;D:\prjAgraria\lib\ext\log4j-1.2.8.jar;D:\prjAgraria\lib\ext\odmg-3.0.jar;D:\prjAgraria\lib\ext\oscache-2.0.jar;D:\prjAgraria\lib\ext\proxool-0.8.3.jar;D:\prjAgraria\lib\ext\swarmcache-1.0rc2.jar;D:\prjAgraria\lib\ext\xalan-2.4.0.jar;D:\prjAgraria\lib\ext\xerces-2.4.0.jar;D:\prjAgraria\lib\ext\xml-apis.jar'
'au.capper.agraria.AppRunner'

The ' characters around the executable and arguments are
not part of the command.
Building an AppRunner
<snip>
Ending Main





---------------------------------------------------------------------
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


Mime
View raw message