You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Fred Janon <fj...@yahoo.com> on 2008/02/27 03:24:02 UTC
Help with java classpath...
Hi,
I am trying to write an Ant build.xml file to compile and run a Java
(Groovy) app without too much success. I spent a day reading the Ant
manual and trying all sorts of things. The ant file builds the classes
correctly but apparently fails to include the current directory at
runtime. I think my classpath in the Ant file is not specified
properly, I can't get Ant to include the current directory in the java
classpath. I can run my app from the Windows command line like the
following and that's what I want Ant to run:
C:\Groovy_JPADownstream>java -cp
./lib/derby.jar;./lib/derbyclient.jar;./lib/toplink-essentials.jar;%GROOVY_HOME%/embeddable/groovy-all-1.5.4.jar;./classes;.
downstream/PopulateDownstream
but when I run the Ant file I get the following error message that
seems to indicate that the "META-INF\persistence.xml" file is not found
by JPA:
[java] java.lang.NullPointerException
[java] at
oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:120)
[java] at
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
meaning that it doesn't see the META-INF/persistence.xml file from the
current directory
Here are the build file and the file structure:
<project name = "GroovyJPA" default = "run" basedir = ".">
<property environment = "env"/>
<property name = "persistenceconfig.dir" location = "**/*"/> <!-- We
need the current dir here -->
<property name = "lib.dir" location = "lib"/>
<property name = "src.dir" location = "src"/>
<property name = "classes.dir" location = "classes"/>
<!-- Groovy jar -->
<path id = "groovy.classpath">
<fileset dir = "${env.GROOVY_HOME}/embeddable/"/>
</path>
<!-- Application jars: DerbyDB, JPA Toplink + persistence.xml -->
<path id = "app.classpath">
<fileset dir = "${env.GROOVY_HOME}/embeddable/"/>
<pathelement location="${classes.dir}"/>
<!-- Should be:
../lib/derby.jar;../lib/derbyclient.jar;../lib/toplink-essentials.jar
-->
<fileset dir = "${lib.dir}"/>
<!-- /META-INF/persistence.xml -->
<pathelement location="${persistenceconfig.dir}"/>
</path>
<taskdef name ="groovyc"
classname = "org.codehaus.groovy.ant.Groovyc"
classpathref = "groovy.classpath"/>
<target name = "compile">
<mkdir dir = "${classes.dir}"/>
<groovyc
destdir = "${classes.dir}"
srcdir = "${src.dir}"
includes = "*.groovy"
classpathref = "app.classpath"
/>
</target>
<!-- This works: C:\Groovy_JPADownstream>java -cp
./lib/derby.jar;./lib/derbyclient.jar;./lib/toplink-essentials.jar;%GROOVY_HOME%/embeddable/groovy-all-1.5.4.jar;./classes;.
downstream/PopulateDownstream -->
<target name = "run" depends = "compile">
<java classname = "downstream.PopulateDownstream">
<classpath refid = "app.classpath"/>
</java>
</target>
</project>
==================
C:\Groovy_JPADownstream\build.xml
C:\Groovy_JPADownstream\lib
C:\Groovy_JPADownstream\lib\derby.jar
C:\Groovy_JPADownstream\lib\derbyclient.jar
C:\Groovy_JPADownstream\lib\toplink-essentials-agent.jar
C:\Groovy_JPADownstream\lib\toplink-essentials.jar
C:\Groovy_JPADownstream\META-INF
C:\Groovy_JPADownstream\META-INF\persistence.xml
C:\Groovy_JPADownstream\src
C:\Groovy_JPADownstream\src\Location.groovy
C:\Groovy_JPADownstream\src\LocationType.groovy
C:\Groovy_JPADownstream\src\PopulateDownstream.groovy
C:\Groovy_JPADownstream\src\QueryDownstream.groovy
C:\Groovy_JPADownstream\classes
C:\Groovy_JPADownstream\classes\downstream
C:\Groovy_JPADownstream\classes\downstream\Location.class
C:\Groovy_JPADownstream\classes\downstream\LocationType.class
C:\Groovy_JPADownstream\classes\downstream\PopulateDownstream.class
C:\Groovy_JPADownstream\classes\downstream\QueryDownstream.class
Thanks,
Fred
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org