title: Hibernate java.lang.ClassCastException: _$$_javassist_856 cannot be cast to javassist.util.proxy.Proxy when using Websphere Shared Library
body: <p><strong>Websphere 8.0.0.11</strong></p>
  
  <p><strong>Hibernate 4.2.21.Final</strong></p>
  
  <p>I have found many questions about this same problem but none of them worked for me.</p>
  
  <p>If I deploy the application in Websphere it works OK. </p>
  
  <p>However we have defined a shared library that contains all the third party libraries (spring, hibernate, javassist, etc) so that our WARs are thinner.</p>
  
  <p>This way during deployment we associate our thin WAR against that Websphere shared library.</p>
  
  <p>The point is that when we deploy the application this way the <code>ClassCastException Hibernate exception _$$_javassist_856 cannot be cast to javassist.util.proxy.Proxy</code> is thrown.</p>
  
  <p>I have checked the loaded jars in the websphere console and can only see one javassist jar (3.18.1-GA)  in the classpath.</p>
  
  <p>Why could this be happening?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I have also tried using PARENT_FIRST and PARENT_LAST class loading.</p>
  
  <p><strong>UPDATE 2</strong> </p>
  
  <p>I just found out that Websphere is loading its own javassist jar:</p>
  
  <pre><code>URL location = ProxyFactory.class.getProtectionDomain().getCodeSource().getLocation(); 
  logger.info("{}", location);
  </code></pre>
  
  <p>It prints: <code>file:/opt/IBM/WebSphere/AppServer/plugins/javassist.jar</code></p>