-->
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: ClassCastException _$$_javassist_
PostPosted: Fri Sep 25, 2009 2:41 pm 
Newbie

Joined: Fri Sep 25, 2009 1:09 pm
Posts: 1
Hi there!

Last week I update the hibernate.jar from version 3.2 to 3.3.2-GA. Unfortunately, I get an error about class cast and _$$javassit_ with a super class (First time I use inheritance with hibernate). With hibernate 3.2 everything was working just right.

I have a super class called AFEPlaza with two subclasses: CentroCostoAFEPuesto and ProyectoInstitucionalAFEPuesto.

This is the code line where I get the error:
Code:
return new BigDecimal(((CentroCostoAFEPuesto) this.plaza).getMaxHorasUniv());


This is the error message I get:
Code:
java.lang.ClassCastException: mx.edu.um.afe.model.AFEPlaza_$$_javassist_68 cannot be cast to mx.edu.um.afe.model.CentroCostoAFEPuesto
        at mx.edu.um.afe.model.ContratoAFEAlumno.getMaximoHoras(ContratoAFEAlumno.java:260)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197)
        at mx.edu.um.afe.model.ContratoAFEAlumno_$$_javassist_83.getMaximoHoras(ContratoAFEAlumno_$$_javassist_83.java)
        at mx.edu.um.afe.service.impl.InformeAFEHorasManagerImpl.calcularBecaAdicional(InformeAFEHorasManagerImpl.java:158)
        at mx.edu.um.afe.service.impl.InformeAFEHorasManagerImpl.saveInformeAFEHoras(InformeAFEHorasManagerImpl.java:63)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:203)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:162)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:209)
        at $Proxy86.saveInformeAFEHoras(Unknown Source)
        at mx.edu.um.afe.webapp.action.InformeAFEHorasAction.save(InformeAFEHorasAction.java:229)


Please, if someone could help me to know what is _$javassist_ and how to handle that kind of classes... Thx!


Top
 Profile  
 
 Post subject: Re: ClassCastException _$$_javassist_
PostPosted: Sat Sep 26, 2009 9:21 pm 
Newbie

Joined: Sat Sep 26, 2009 9:18 pm
Posts: 1
I have the same problem too.


Top
 Profile  
 
 Post subject: Re: ClassCastException _$$_javassist_
PostPosted: Sun Sep 27, 2009 7:31 am 
Senior
Senior

Joined: Mon Jul 07, 2008 4:35 pm
Posts: 141
Location: Berlin
Hi joslash,

the class
Code:
mx.edu.um.afe.model.AFEPlaza_$$_javassist_68
is a Hibernate generated proxy of your super class AFEPlaza. Since the proxy is not a subclass of your class CentroCostoAFEPuesto it cannot be cast to it.

If you require to have these casts in your app you should implement an interface with your business methods for each of your classes. Create one for your super class AFEPlaza and let the super class implement it. Also create one for each subclass and let them implement it. The interfaces for the subclasses should extend the superclass's interface.

Then, in your mapping tell Hibernate to use these interfaces for proxying with
Code:
<class ... proxy="InterfaceName">


Then casting should work since your proxied object will then be a subclass of the interface and as such you can at least cast it to that interface.

CU
Froestel

_________________
Have you tried turning it off and on again? [Roy]


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.