Take a look at the following wiki page [1], which has an example ANT
task, which can be used with the complete OpenJPA binary download (as
there are some required JARs included in the lib directory, which
includes commons-lang-2.1.jar).
[1] http://openjpa.apache.org/enhancement-with-ant.html
-Donald
jack.terranova wrote:
Sounds like this poster had this issue too ...
http://n2.nabble.com/Please-help-me-enhancing-my-classes-td209164.html#a209166
http://n2.nabble.com/Please-help-me-enhancing-my-classes-td209164.html#a209166
... but their issue just went away.
I am trying to enhance at build time using Ant...
<target name="enhance">
<!-- define the openjpac task; this can be done at the top of the -->
<!-- build.xml file, so it will be available for all targets -->
<taskdef name="openjpac"
classname="org.apache.openjpa.ant.PCEnhancerTask">
<classpath>
<fileset dir="src/META-INF" >
</fileset>
<pathelement
path="/home/jack/programs/commons-lang-2.4/commons-lang-2.4.jar" />
<pathelement
path="/home/jack/programs/apache-openjpa-1.2.1/openjpa-1.2.1.jar" />
</classpath>
</taskdef>
<!-- invoke enhancer on all .java files below the model directory -->
<openjpac>
<fileset dir="build/classes">
<include name="**/*.class"/>
</fileset>
</openjpac>
</target>
commons-lang-2.4.jar seems to be the culprit. Originally I was getting a
ClassNotFound for a commons/lang class. So I added the jar into the
classpath and get this exception ...
[openjpac] java.util.zip.ZipException: error in opening zip file
[openjpac] at java.util.zip.ZipFile.open(Native Method)
[openjpac] at java.util.zip.ZipFile.<init>(Unknown Source)
[openjpac] at java.util.zip.ZipFile.<init>(Unknown Source)
[openjpac] at
org.apache.tools.ant.AntClassLoader.getResourceURL(AntClassLoader.java:1028)
[openjpac] at
org.apache.tools.ant.AntClassLoader$ResourceEnumeration.findNextResource(AntClassLoader.java:147)
[openjpac] at
org.apache.tools.ant.AntClassLoader$ResourceEnumeration.<init>(AntClassLoader.java:109)
[openjpac] at
org.apache.tools.ant.AntClassLoader.findResources(AntClassLoader.java:975)
[openjpac] at java.lang.ClassLoader.getResources(Unknown Source)
...I've struggles with all sorts of workarounds including downloading
different versions of common-lang thinking maybe the jar is corrupt. But I
think this is an openjpa issue.
Enhancing at runtime works great with the agent - so that is my workaround
for now.
Thanks in advance.