openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastian Souza <>
Subject Re: openjpac Ant task
Date Fri, 14 Dec 2007 17:36:03 GMT

Hi, iam a opnejpa newbie and iam trying to build my projects with the
enhancer task.

I read your mails and may be you can help me. 

i have different projects for entities and for the persistent logic. 

I mean this:
MyEntities projects where the classes to enhance reside, then i have a
Persistence project where i put the persistence.xml and orml.xml and common
logic for peristent objects.

Where i put the enhancer? in the build.xml of my entities project or in the
persistence project? 
if is the first option, how i link to the Persistent project persistence.xml
and orm.xml in the entities build.xml

thanks in advance.

mikedd wrote:
> Hi Dan,
> Enhancement is not database specific. The PCEnhancer ant task requires a
> configuration to be specified and one of the convenient ways to do so is
> to
> use persistence.xml. The PCEnahncer task should be able to handle a
> missing
> configuration file, but unfortunately it doesn't at this time.
> You can work around the problem by specifying a different configuration
> file
> when you run the enhancer. Something like this should work :
>     <taskdef name="enhance"
> classname="org.apache.openjpa.ant.PCEnhancerTask
> ">
>         <classpath>
>             <path refid="jpa.provider.cp"/>
>         </classpath>
>     </taskdef>
>     <target name="enhance">
>         <enhance>
>             <!-- <config
> propertiesFile="${src.location}/META-INF/persistence.xml"/>
> -->
>             <config propertiesFile="openjpa-dev.xml"/>
>             <classpath>
>                 <path refid="entity.cp"/>
>                 <path refid="jpa.used.cp"/>
>             </classpath>
>             <fileset dir="${classes.location}">
>                 <include name="**/*.class"/>
>             </fileset>
>         </enhance>
>     </target>
> contents of openjpa-dev.xml :
> <?xml version="1.0"?>
> <persistence xmlns=""
>     xmlns:xsi=""
>     xsi:schemaLocation="
>     version="1.0">
>     <persistence-unit name="none"/>
> </persistence>
> I believe that will work for you., even though it is a bit kludgy. Would
> you
> mind opening a JIRA issue at
> report the problem?
> There are some configuration properties which do pertain to enhancement,
> for
> example openjpa.DetachState so there are cases where a configuration is
> desirable. The task should be able to handle the absence of one though, or
> at least handle something like
>     <target name="enhance">
>         <enhance>
>              <config/>
>         </enhance>
>     </target>
> If you don't override the defaults.
> Hope this helps,
> -Mike
> On Dec 13, 2007 10:34 PM, Daniel Dyer <> wrote:
>> I've been using the runtime agent approach for enhancing my classes and
>> now I would like to switch to build-time enhancement.
>> I'd appreciate it if somebody could help me understand exactly what is
>> required.
>> What I would like to know is what does the openjpac Ant task need the
>> persistence.xml for?  Is enhancement specific to the particular database
>> that I am using?  There is apparently no other information in there that
>> could be useful (I already specify which classes to look at by providing
>> a
>> fileset to the Ant task).
>> My problem is that when I add the persistence.xml to the Ant task, it
>> fails because I have specified the <jar-file> element and the JAR file it
>> references does not exist yet (how can it? I have to enhance the classes
>> before packaging them in a JAR).  If I don't provide the persistence.xml
>> it fails because "MetaDataFactory could not be configured".  I suppose I
>> could create a different persistence.xml just for this step, but is it
>> necessary?
>> Also, currently (with the runtime agent enhancement) I am using the same
>> entity classes with 2 different databases (I use H2 for the unit tests
>> and
>> MySQL for the actual application).  If enhancement is database specific,
>> I
>> guess I can't do this with build-time enhancement (I would need 2
>> versions
>> of the enhanced classes).
>> Thanks for any insights you can give me,
>> Dan.
>> --
>> Daniel Dyer

View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message