-->
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.  [ 2 posts ] 
Author Message
 Post subject: Bytecode enhancement failed - ClassCastException [SOLVED]
PostPosted: Wed Mar 08, 2017 11:20 am 
Beginner
Beginner

Joined: Wed Sep 03, 2003 9:31 am
Posts: 26
I'm using Hibernate 5.2.8-Final downloaded from Maven with all required dependencies and their required versions.

When I use session.load on any entity the following error occurs:
Code:
MyEntity e1 = session.load(MyEntity.class, "1");

ERROR - HHH000142: Bytecode enhancement failed: package.name.MyEntity
java.lang.ClassCastException: package.name.MyEntity_$$_javassist_110 cannot be cast to javassist.util.proxy.Proxy
   at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.getProxy(JavassistProxyFactory.java:123)
   at org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:761)
   at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:4587)
.
.
.
etc


Session.get works fine, but if the entity have any relationships mapped (eg. @ManyToOne) the same error occurs.

Digging into Hibernate code (more preciselly into the class org.hibernate.proxy.pojo.javassist.JavassistProxyFactory) I found this:
Code:
final HibernateProxy proxy = (HibernateProxy) proxyClass.newInstance();
( (Proxy) proxy ).setHandler( initializer );

Also found that org.hibernate.proxy.HibernateProxy and javassist.util.proxy.Proxy doesn't extend or implement each other, so seems to me that type casting is problematic. Is this a bug?

If not I really don't understanding why is this hapening. Can someone help?

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: Bytecode enhancement failed - ClassCastException [SOLVED]
PostPosted: Wed Mar 08, 2017 12:16 pm 
Beginner
Beginner

Joined: Wed Sep 03, 2003 9:31 am
Posts: 26
I had a dependency conflict with javassist. For some reason my project was considering Ognl's javassist version (older) instead of Hibernate's. Didn't give a lot of thought about this, only excluded Ognl's javassist dependency.

Hope this information can be usefull for someone.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.