You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Gul Onural <on...@nortel.com> on 2007/11/01 11:42:02 UTC

org.apache.openjpa.persistence.ArgumentException

Hi,

I enhanced my JPA class using PCEnhancer, but I am still getting
org.apache.openjpa.persistence.ArgumentException, when
openjpa attempts to cast instance of my JPA class.

[11/1/07 5:26:44:423 GMT-05:00] 00000020 SystemErr     R <0.0.0 nonfatal
user error> org.apache.openjpa.persistence.ArgumentException: Attempt to
cast instance "com.test.Employee" to PersistenceCapable failed.  Ensure
that it has been enhanced.

What would cause this to happen ?

What type of debugging can tell me more about why this is happening ? 

Would it be because of incorrect packaging of JPA files ? 

I am using JPA files from an Mbean (management bean) in IBM Websphere.
My Mbean is packaged a war file. Where does openjpa look for
JPA classes and persistence.xml file in this case ? 

Gul




Re: org.apache.openjpa.persistence.ArgumentException

Posted by Craig L Russell <Cr...@Sun.COM>.
Hi Gul,

On Nov 1, 2007, at 3:42 AM, Gul Onural wrote:

>
> Hi,
>
> I enhanced my JPA class using PCEnhancer, but I am still getting
> org.apache.openjpa.persistence.ArgumentException, when
> openjpa attempts to cast instance of my JPA class.
>
> [11/1/07 5:26:44:423 GMT-05:00] 00000020 SystemErr     R <0.0.0  
> nonfatal
> user error> org.apache.openjpa.persistence.ArgumentException:  
> Attempt to
> cast instance "com.test.Employee" to PersistenceCapable failed.   
> Ensure
> that it has been enhanced.
>
> What would cause this to happen ?

This does sound like a class loader problem. You might be getting an  
unenhanced class instead of your enhanced class. Are you enhancing in  
place, and have no other copy of the class somewhere (in your class  
path)?
>
> What type of debugging can tell me more about why this is happening ?

Can you put a statement into your code like (if ! 
presumablyEnhancedInstance instanceof PersistenceCapable) {throw  
RuntimeException("PresumablyEnhancedClass not enhanced");}
>
> Would it be because of incorrect packaging of JPA files ?

That's my guess.

>
> I am using JPA files from an Mbean (management bean) in IBM Websphere.
> My Mbean is packaged a war file. Where does openjpa look for
> JPA classes and persistence.xml file in this case ?

I don't know this environment well enough to comment.

Craig
>
> Gul
>
>
>

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!