Thanks Ravi, I found that if I added my classes to the persistence.xml it all works fine but I thought I didn't have to do that, or am I mistaken.
Regards Chris -----Original Message----- From: Ravi Palacherla [mailto:[email protected]] Sent: Sunday, 5 July 2009 1:32 AM To: [email protected]; [email protected] Subject: RE: Deployment Hi Chris, There are two ways to enhance classes. 1) Build time enhancement Here is a link for build time enhancement: http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_pc _enhance_build Ant task for that is http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_in tegration_enhance 2) Run time enhancement. http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_pc _enhance_runtime If you did build time enhancement then Decompile your class file and see if the class implements PersistenceCapable ? If it implements PersistenceCapable that means the class is enhanced. Regards, Ravi. -----Original Message----- From: C N Davies [mailto:[email protected]] Sent: Saturday, July 04, 2009 3:49 AM To: [email protected] Subject: Deployment I'm having an issue when running my application in that OpenJPA is complaining my class has not been enhanced but the class looks fine to me, can anyone see if I am missing something stupid please. Here is the top of the stack trace: <openjpa-1.2.0-r422266:683325 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: Attempt to cast instance "com.trm.core.curre...@cf3539" to PersistenceCapable failed. Ensure that it has been enhanced. FailedObject: com.trm.core.curre...@cf3539 <openjpa-1.2.0-r422266:683325 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: Attempt to cast instance "com.trm.core.curre...@cf3539" to PersistenceCapable failed. Ensure that it has been enhanced. FailedObject: com.trm.core.curre...@cf3539 I am wondering if is because of how I am using the objects. Basically the code is loading some data from a file, depending on some configuration the code will try to create the appropriate objects and then persist them. In order to make the code abstract, the code loads the data then creates a generic object and calls it setters to populate the data. Hence when the EntityManager is called to persist the object it I am passing it a generic object since I can't cast the object to the it's actual class at run time. >From the stack trace it seems that OpenJPA knows the correct class type so I don't understand why it is complaining. Here is my class: @Entity @Table(name="currency") public class Currency implements Serializable { /** * */ private static final long serialVersionUID = 1L; @Id // @GeneratedValue(strategy=GenerationType.AUTO) private String isocode; private String name; private String country; public Currency(){ } /** * @param isocode the isocode to set */ public void setIsocode(String isocode) { this.isocode = isocode; } /** * @return the isocode */ public String getIsocode() { return isocode; } /** * @param name the name to set */ public void setName(String name) { this.name = name; } /** * @return the name */ public String getName() { return name; } /** * @param country the country to set */ public void setCountry(String country) { this.country = country; } /** * @return the country */ public String getCountry() { return country; } Thanks for any advice. Chris
