0

An EAR file is deployed successfuly on Websphere Traditional (For both 8.5.5 and 9.0) and having below structure:

  EApplication.ear
          |--> META-INF
                   |-->application.xml
          |--> Application jars
          |--> lib
                ---> Third party Jars
         
          |--> webapp1
                 |---> META-INF 
                          |--> MANIFEST
                 |----->WEB-INF 
                          |--> classes (Contain war classes)
                          |--> lib (Third party lib)
                          
          |--> webapp2
                 |---> META-INF 
                          |--> MANIFEST
                 |----->WEB-INF 
                          |--> classes (Contain war classes)
                          |--> lib (Third party lib)
                          

In WebSphere Traditional PARENT_LAST strategy is used along with separate classloader for each war. I am migrating the application to WebSphere liberty and classes and lib of war are not getting loaded by classloader. Only the EAR libraries are getting loaded. I have also tried to add classloader delegation to parentLast in server.xml for war files but not seeing any difference.

<classloader apiTypeVisibility="+third-party" delegation="parentLast"/>

Exception:

Caused by: java.lang.ClassNotFoundException: <Application class present in webapp1/WEB-INF/classes>
    at com.ibm.ws.classloading.internal.AppClassLoader.findClassCommonLibraryClassLoaders(AppClassLoader.java:734)
    at com.ibm.ws.classloading.internal.AppClassLoader.findClass(AppClassLoader.java:319)
    at com.ibm.ws.classloading.internal.AppClassLoader.findOrDelegateLoadClass(AppClassLoader.java:706)
    at com.ibm.ws.classloading.internal.AppClassLoader.loadClass(AppClassLoader.java:578)
    at com.ibm.ws.classloading.internal.AppClassLoader.loadClass(AppClassLoader.java:545)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 134 more

server.xml:

<enterpriseApplication location="EApplication.ear">
       
        <web-ext context-root="/webapp1" moduleName="webapp1"/>
        <web-ext context-root="/webapp2" moduleName="webapp2"/>
       
        <application-bnd>
            .....................       
       </application-bnd>
       
</enterpriseApplication>

Note: If I copy the war/lib (third party lib) to EAR/lib then classloader is able to load those jars, but that might not be an standard way and still the problem persist for war/classes. Please suggest if any Websphere liberty specific configuration is needed to acheive for same. Thanks.

Technogix
  • 77
  • 13
  • The fact that the scenario works if you copy the classes to the WAR lib makes it sound like there is a hierarchy issue here - something in the EAR has the dependency on a class in the WAR, and since the EAR is a parent of the WAR, that class isn't available to it. It'd be difficult to tell without actual trace analysis what that specific class is, though. As for what is "standard"... that's really up to the needs of your environment. If you have a lot of interdependency between stuff in the WAR and EAR, you might need more stuff in a common location. – Jarid Apr 03 '23 at 12:14
  • 1
    First of all Liberty is not WAS and you should not use PARENT_LAST in this case as server classloaders are separate from your apps class loaders and there is no need for that. Your EAR should contain all needed classes. Second, you need to fix packaging - all sheard libs should go to ear/lib, then you have your ejb.jars, then you have web modules which may depend on ear/lib and ejb.jars, but not the other way around. In your case you probably have libs dependent on war classes/libs which is incorrect approach. – Gas Apr 06 '23 at 08:07

0 Answers0