title: JavassistProxyFactory failing with java.lang.ClassCastException: mypkg.myObjE_$$_javassist_0 cannot be cast to javassist.util.proxy.Proxy
body: <p>I'm using hibernate 5.0.2 with weblogic 12. I have a standalone app that initializes the context and then calls a EJB in weblogic. I'm getting below error message when i run my standalone app.</p>
  
  <blockquote>
    <p>Oct 20, 2015 8:56:52 PM org.hibernate.proxy.pojo.javassist.JavassistProxyFactory deserializeProxy
    ERROR: HHH000142: Javassist Enhancement failed: com.fedex.net2.persistence.pojo.ParameterDefinitionE
    java.lang.ClassCastException: com.fedex.net2.persistence.pojo.ParameterDefinitionE_$$_javassist_0 cannot be cast to javassist.util.proxy.Proxy
            at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.deserializeProxy(JavassistProxyFactory.java:156)
            at org.hibernate.proxy.pojo.javassist.SerializableProxy.readResolve(SerializableProxy.java:116)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:483)
            at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1104)
            at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1810)
            at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
            at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
            at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
            at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
            at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
            at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
            at java.util.ArrayList.readObject(ArrayList.java:791)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:483)
            at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
            at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1896)
            at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
            at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
            at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
            at weblogic.utils.io.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:208)
            at weblogic.rjvm.MsgAbbrevInputStream.readObject(MsgAbbrevInputStream.java:602)
            at weblogic.utils.io.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:204)
            at weblogic.rmi.internal.ObjectIO.readObject(ObjectIO.java:62)
            at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:264)
            at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:477)
            at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:285)
            at com.fedex.net2.parameter.ParameterSBean_cswnpo_EOImpl_12130_WLStub.findAllParameterValuesListForSeqNo(Unknown Source)
            at com.fedex.net2.parameter.Parameter.getParamValue(Parameter.java:122)
            at com.fedex.net2.comm.daemon.ChannelDef.getChnlParams(ChannelDef.java:310)
            at com.fedex.net2.comm.daemon.CommInDaemon.connectChannel(CommInDaemon.java:696)
            at com.fedex.net2.comm.daemon.CommInDaemon.main(CommInDaemon.java:278)</p>
  </blockquote>
  
  <p>Followed by below exception.</p>
  
  <blockquote>
    <p>Exception in thread "main" org.hibernate.HibernateException: HHH000142: Javassist Enhancement failed: com.fedex.net2.persistence.pojo.ParameterDefinitionE
            at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.deserializeProxy(JavassistProxyFactory.java:163)
            at org.hibernate.proxy.pojo.javassist.SerializableProxy.readResolve(SerializableProxy.java:116)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:483)
            at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1104)
            at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1810)
            at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
            at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
            at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
            at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
            at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
            at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
            at java.util.ArrayList.readObject(ArrayList.java:791)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:483)
            at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
            at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1896)
            at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
            at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
            at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
            at weblogic.utils.io.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:208)
            at weblogic.rjvm.MsgAbbrevInputStream.readObject(MsgAbbrevInputStream.java:602)
            at weblogic.utils.io.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:204)
            at weblogic.rmi.internal.ObjectIO.readObject(ObjectIO.java:62)
            at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:264)
            at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:477)
            at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:285)
            at com.fedex.net2.parameter.ParameterSBean_cswnpo_EOImpl_12130_WLStub.findAllParameterValuesListForSeqNo(Unknown Source)
            at com.fedex.net2.parameter.Parameter.getParamValue(Parameter.java:122)
            at com.fedex.net2.comm.daemon.ChannelDef.getChnlParams(ChannelDef.java:310)
            at com.fedex.net2.comm.daemon.CommInDaemon.connectChannel(CommInDaemon.java:696)
            at com.fedex.net2.comm.daemon.CommInDaemon.main(CommInDaemon.java:278)
    Caused by: java.lang.ClassCastException: com.fedex.net2.persistence.pojo.ParameterDefinitionE_$$_javassist_0 cannot be cast to javassist.util.proxy.Proxy
            at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.deserializeProxy(JavassistProxyFactory.java:156)
            ... 35 more</p>
  </blockquote>
  
  <p>What i'm not understanding is why my standalone app is failing to access data. Is it related to Lazy loading. Am i doing something wrong.</p>
  
  <p>I have correct jars in the class path. Verified 100 times so far. Still not able to figure out why?</p>
  
  <p>Any thoughts???</p>