Friday, November 15, 2019

Parent ClassLoader Last on WebLogic

There were some requirements recently to convert some source files from WebSphere to WebLogic as the deployment target. I'm not particuarly familiar with WebLogic as the projects I've been involved in, largely employs WebSphere. Some hijinks ensued and I'd reached a familiar problem regarding NoClassDefFoundError.

My first lead pointed me to this question, where a helpful answer gave some insight to how WebLogic works. The solution was to add a <prefer-web-inf-classes> XML configuration. My assessment at this stage was that this issue seems similar to how WebSphere deals with the ClassLoader problem, where in certain cases, priority needs to be given to files found in the application, due to identically named classes.

Option to set the ClassLoader policy from within WebSphere Admin Console

I proceeded to try and find out if there was a configuration option to set this from within the WebLogic admin console. There was not. A second link seemed to corroborate this finding. And then I found the official documentation. The only was to set this up was via an XML entry from the weblogic.xml file as part of the deployed application:
<weblogic-web-app>
  <container-descriptor>
    <prefer-web-inf-classes>true</prefer-web-inf-classes>
  </container-descriptor>
</weblogic-web-app>
This wasn't a convenient fix, but it was a solution after all. Albeit it certainly would have been helpful, had this been made available from the admin console.