Hi Roger,
The entities are definitely not getting enhanced. Have you tried specifying
the .class files instead of the .java ones?
ie :
<openjpac>
<!-- classpath where the tool look for classes to
enhance. This is the default location in a NB project
directory layout where classes are built -->
<classpath>
<pathelement location="${basedir}/build/classes"/>
</classpath>
<!-- I put it in here. See below the persistence.xml file -->
<config propertiesFile="${basedir}/src/META-INF/persistence.xml"/>
* <fileset dir="${basedir}/build/classes">
<include name="**/entities/*.class"/>
</fileset>
* </openjpac>
-mike
On Tue, Jun 16, 2009 at 6:49 AM, Roger Varley
<[email protected]>wrote:
> 2009/6/16 Michael Dick <[email protected]>:
> > Hi,
> >
> > I have very little (and very out of date) experience with Netbeans. Could
> > you post the ant task that you're using to run the Enhancer?
> >
> > My guess is that the class files are enhanced but are written somewhere
> > outside the normal Netbeans classpath, or you need to trigger a classpath
> > refresh in Netbeans (I'm assuming you're running in NB).
> >
> > One way to tell whether the class has been enhanced is to run javap on
> it.
> > For example :
> > $ javap -classpath . org.apache.openjpa.persistence.simple.Person
> > public class org.apache.openjpa.persistence.simple.Person extends
> > java.lang.Object *implements
> org.apache.openjpa.enhance.PersistenceCapable*{
> >
> > If the class implements PersistenceCapable then the enhancer has run and
> > it's ready for use.
> >
> > Hope this helps, maybe someone on the list with more experience with
> > Netbeans can offer some advice.
> >
> > -mike
> >
>
> Hi Mike
>
> Thanks for the quick response. Below is my ant script (relevant
> section) from the project build.xml and
> the output from javap on one of my entity classes which seems to
> suggest that the enhanced classes are not where I think they should
> be,
>
>
> --------------------------------- Ant Task
> ---------------------------------
>
> <property name="jpa-home"
> value="${user.home}/java-packages/openjpa"/>
>
> <path id="jpa.classpath">
> <pathelement path="${jpa-home}/openjpa-1.2.1.jar"/>
> <fileset dir="${jpa-home}/lib">
> <include name="*.jar"/>
> </fileset>
> </path>
>
> <taskdef name="openjpac"
> classname="org.apache.openjpa.ant.PCEnhancerTask">
> <classpath refid="jpa.classpath"/>
> </taskdef>
>
> <target name="-post-compile" >
> <!-- <target name="jpa-enhance" depends="compile"> -->
> <echo message="Enhancer Running"/>
> <property name="jpa-home"
> value="${user.home}/java-packages/openjpa"/>
>
> <openjpac>
> <!-- classpath where the tool look for classes to
> enhance. This is the default location in a NB project
> directory layout where classes are built -->
> <classpath>
> <pathelement
> location="${basedir}/build/classes"/>
> </classpath>
> <!-- I put it in here. See below the
> persistence.xml file -->
> <config
> propertiesFile="${basedir}/src/META-INF/persistence.xml"/>
> <fileset dir="./src">
> <include name="**/entities/*.java"/>
> </fileset>
>
> </openjpac>
>
> </target>
>
> ------- End Ant Task --------
>
> ------ Begin Javap Output -----
>
> Compiled from "Ecu.java"
> public class com.blackbox.flashloader.entities.Ecu extends
> java.lang.Object implements java.io.Serializable{
> protected com.blackbox.flashloader.entities.EcuPK ecuPK;
> public com.blackbox.flashloader.entities.Ecu();
> public
> com.blackbox.flashloader.entities.Ecu(com.blackbox.flashloader.entities.EcuPK);
> public
> com.blackbox.flashloader.entities.Ecu(com.blackbox.flashloader.entities.EcuPK,
> java.lang.String, java.lang.String, char);
> public com.blackbox.flashloader.entities.Ecu(java.lang.String,
> java.lang.String);
> public com.blackbox.flashloader.entities.EcuPK getEcuPK();
> public void setEcuPK(com.blackbox.flashloader.entities.EcuPK);
> public java.lang.String getDescription();
> public void setDescription(java.lang.String);
> public java.lang.String getNetwork();
> public void setNetwork(java.lang.String);
> public char getFitment();
> public void setFitment(char);
> public java.util.Collection getPartsLinkCollection();
> public void setPartsLinkCollection(java.util.Collection);
> public com.blackbox.flashloader.entities.Model getModel();
> public void setModel(com.blackbox.flashloader.entities.Model);
> public java.util.Collection getEcuDataIdentifiersCollection();
> public void setEcuDataIdentifiersCollection(java.util.Collection);
> public int hashCode();
> public boolean equals(java.lang.Object);
> public java.lang.String toString();
>
> ---- End Javap Output ----
>
> >
> >
> > On Tue, Jun 16, 2009 at 5:55 AM, B.L. Zeebub <
> [email protected]>wrote:
> >
> >>
> >> Hi
> >>
> >> I've just spent the last three days wrestling with the enhancer and I'm
> now
> >> ready to throw the computer out of a fifth floor window. I spent the
> first
> >> day or so wrestling with error messages trying to set-up the ant
> enhancer
> >> task in Netbeans 6.5.1/Linux (Debian Lenny). (Googling for examples
> brought
> >> up many examples that were all slightly different and none of them
> actually
> >> worked until I got lucky). I finally got the process to run without
> falling
> >> over. I then tried to run my first program. Next problem was that when
> the
> >> program tried to create the EntityManagerFactory the program would crash
> >> messages similair to "Caused by: <openjpa-1.2.1-r752877:753278 fatal
> user
> >> error> org.apache.openjpa.persistence.ArgumentException: The type "class
> >> com.mydomain.flashloader.entities.DataIdentifiersPK" has not been
> >> enhanced."
> >>
> >> I've finally resolved that - I used Netbeans create entities from
> database
> >> facility. Netbeans created a class for every table in the database and a
> >> classPK file for every table that has multi-column primary keys.
> However,
> >> it
> >> only put the table class entities into the persistance.xml and omitted
> the
> >> classPK files. So I added all the classPK classes into persistance xml,
> >> rebuilt the project and now my program starts, creates the
> >> EntityManagerFactory without crashing.
> >>
> >> However, I'm left with a message during startup "1120 FlashLoaderPU
> INFO
> >> [main] openjpa.Enhance - Creating subclass for "[<every entity and
> entityPK
> >> in the database listed here>]" This means that your application will be
> >> less
> >> efficient and will consume more memory than it would if you ran the
> OpenJPA
> >> enhancer. Additionally, lazy loading will not be available for
> one-to-one
> >> and many-to-one persistent attributes in types using field access; they
> >> will
> >> be loaded eagerly instead."
> >>
> >> So I seem to have spent the last three days going around in a complete
> >> circle. I would be extremely grateful for any pointers as to what on
> earth
> >> is going on.
> >>
> >> Regards
> >> --
> >> View this message in context:
> >>
> http://n2.nabble.com/-Newbie--OPenJPA-%281.2.1%29-Enhancement-woes-tp3085661p3085661.html
> >> Sent from the OpenJPA Users mailing list archive at Nabble.com.
> >>
> >>
> >
>