-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: java.lang.ClassCastException: $Proxy3
PostPosted: Wed Jun 14, 2006 8:11 am 
Newbie

Joined: Wed Jun 14, 2006 7:43 am
Posts: 1
Hello list,

I am running into an exception and don't know, what it tells me. But first, two words about what I am doing:
I have an entity that I need to map. The entity contains an embedded object, which is derived from a base class. In code:

Code:
@Entity
class MyEntity {
   @Embedded
   private BasicObject object;


and

Code:
@Embeddable
class BasicObject extends VeryBasicObject {


and

Code:
@MappedSuperclass
class VeryBasicObject {


The situation, as given above, works! I can map the values in VeryBasicObject to columns and all is fine. But now: Out of various reasons I have the requirement to use an XML mapping (orm.xml) for the VeryBasicObject class.

Should be no problem, I'd think. Just remove the @MappedSuperclass annotation and add <mapped-superclass name="..."/> to the orm.xml.

But when I try that I get this exception:
javax.persistence.PersistenceException: java.lang.ClassCastException: $Proxy3
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:217)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)

...
Caused by: java.lang.ClassCastException: $Proxy3
at org.hibernate.reflection.java.EJB3OverridenAnnotationReader.getMappedSuperclass(EJB3OverridenAnnotationReader.java:1688)
at org.hibernate.reflection.java.EJB3OverridenAnnotationReader.initAnnotations(EJB3OverridenAnnotationReader.java:285)

The exception comes when the EntityManagerFactory is created. I have stripped the code down to a test class and three small pojos and can reproduce the exception. I don't know if I can attach the eclipse project zip here somewhere, but it doesn't look that way. So, if you think it would help to have the reproducing eclipse project, drop me a note and I will send the thing to you by email, it is only 9kB. (The classpath of the project is left empty, I guess you'll know what you have to add to it for hibernate to work :-)).

I am using Hibernate 3.2.0.cr2, EntityManager 3.2.0.cr1 and Annotations 3.2.0.cr1.

Best wishes, Daniel


Top
 Profile  
 
 Post subject: java.lang.ClassCastException: $Proxy3
PostPosted: Mon Jun 19, 2006 10:07 pm 
Newbie

Joined: Fri Mar 17, 2006 7:08 pm
Posts: 2
I'm having the exact same issue, when I attempt to override a mappedSuperclass using a <mapped-superclass /> element in the orm.xml.

Even if I don't override anything and just tell it to use the annotations. eg.

<mapped-superclass class="..." metadata-complete="false">

</mapped-superclass>

Change metadata-complete to true makes no difference, neither does defining anything between the tags.

Looking at the source it appears to be creating a proxy with overridden annotations. I'm going to attempt to debug it when I get time. Definately appears to be a bug in my opinion.

It appears work fine if I override the mapped superclass through the entity tag.

I am using Hibernate 3.2.0.cr2, EntityManager 3.2.0.cr1 and Annotations 3.2.0.cr1.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 28, 2006 6:17 pm 
Newbie

Joined: Thu Sep 23, 2004 2:59 pm
Posts: 5
Same issue here. I created an issue in JIRA:

http://opensource.atlassian.com/project ... se/EJB-204


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.