Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ClassCastExceptions due to upgrade to hibernate 4.2.8 in WebSphere 8.5.5 application container

We recently upgraded hibernate from 4.0.1 to 4.2.8.Final.

Hibernate.4.2.8.Final is depending on javassist-3.18.1-GA. Unfortunately websphere is 8.5.5 is not shipped with latest javassist but it is not my issue. I tried to force websphere to take my javassist jar but I FAILED ( for some reason it is always loading from ${WAS_INSTALL_ROOT}/plugins).

What I tried?

  • Classes loaded with local class loader first (parent last) in websphere console and WEB-INF/lib contains latest javassist jar. But application is not working
  • Put latest javassit jar in ${WAS_INSTALL_ROOT}/lib/ext but no use
  • Added shared library and referenced in application but no luck.
  • If I replace javassist.jar in ${WAS_INSTALL_ROOT}/plugins then application started working but this is not good solution because other web applications might depend on old javassist

My question

How can I use (or inject or refer) latest javassist jar in Websphere 8.5.5?

This #blog helped me to figure our the problem little quickly.

like image 206
Seeta Ramayya Vadali Avatar asked Jan 03 '14 16:01

Seeta Ramayya Vadali


2 Answers

Where did you put parent last, in which window of the console?

Because there are two places in the console where to put parent last, one at the application level, and the other at the WAR level and that is the one that you want to choose.

Put 'Class loader for each WAR file in application' and I believe from inside the screen where you chose that option, click the WAR and set the classloader policy at the WAR level to parent last:

I think the path is this (don't have a console now):

Application -- > Enterprise Application --> application_instance --> Web Module --> Web Module_instance

Have a look at this to see that are two places to set classloader policies, and let me know if you found the setting and if it worked, or a new error is thrown.

Sometimes when we switch the setting we find new errors because other jars where being read from the server and not the WAR, such as bean validation errors etc. If you get a different error non javassist related, it might be caused by that and you can always post it in a new question.

like image 116
Angular University Avatar answered Nov 12 '22 05:11

Angular University


This can be solved by adding the new version of javaassist as a shared library . The details are described here [http://www-01.ibm.com/support/docview.wss?uid=swg27006159#usingserver][1].

The shared library should be assigned against the a new class loader defined at the server configuration. The class loading policy should be PARENT_LAST for this class loader

like image 2
lloyd chandran Avatar answered Nov 12 '22 04:11

lloyd chandran