Search code examples
javahibernatewebspherewebsphere-8javassist

Hibernate java.lang.ClassCastException: _$$_javassist_856 cannot be cast to javassist.util.proxy.Proxy when using Websphere Shared Library


Websphere 8.0.0.11

Hibernate 4.2.21.Final

I have found many questions about this same problem but none of them worked for me.

If I deploy the application in Websphere it works OK.

However we have defined a shared library that contains all the third party libraries (spring, hibernate, javassist, etc) so that our WARs are thinner.

This way during deployment we associate our thin WAR against that Websphere shared library.

The point is that when we deploy the application this way the ClassCastException Hibernate exception _$$_javassist_856 cannot be cast to javassist.util.proxy.Proxy is thrown.

I have checked the loaded jars in the websphere console and can only see one javassist jar (3.18.1-GA) in the classpath.

Why could this be happening?

UPDATE

I have also tried using PARENT_FIRST and PARENT_LAST class loading.

UPDATE 2

I just found out that Websphere is loading its own javassist jar:

URL location = ProxyFactory.class.getProtectionDomain().getCodeSource().getLocation(); 
logger.info("{}", location);

It prints: file:/opt/IBM/WebSphere/AppServer/plugins/javassist.jar


Solution

  • After trying pretty much everything I found on S.O. without any success I decided to downgrade Hibernate to version 4.1.12.Final. This is the maximum 4.x version compatible with Websphere 8.x.