Tuesday, August 23, 2011

Weblogic : Identifying Class Conflict and ClassLoading in deployed ADF Application using CAT Tool in Weblogic

 

List of Class Loader in Weblogic

System Class Loader - Weblogic Classes in weblogic system directory

Domain Class Loader - Domain Classes in domain directory

Application Class Loader - Library from Weblogic-application.xml , APP-INF/lib

WEB APP Class loader - Library from weblogic.xml , WEB-INF/lib , WEB-INF/classes

JSP class loader

Class Conflict

Until Weblogic 10.3.4 there was no tool available in weblogic  to identify class conflict. However , Now weblogic has a tool called CAT (Classloader Analysis Tool) to perform class conflict check.

Let us say you have class call ClassLoadingExample.class in your Ear Application $CLASSPATH.

Also, you have same class in $CLASSPATH of weblogic.

So when you run the application then Weblogic class will be considered ,not the EAR one giving you surprising result.

Filtering Class Loader

This provide us option to configure our deployment description to make sure that our WAR/EAR class are loaded ,not the one in weblogic.

FilteringClassLoader sits between Application and System Class loader. It is child of System Class Loader and Parent of Applicatino Class Loader.

FilteringClassLoader intercept loadClass method and compare className with list of package specified in weblogic-application.xml file. If package matches class name , FilteringClassLoader throws ClassNotFoundException. This exception notifies applicatino classloader to load class from application.

Configure Filtering Class Loader

Add prefer-application-packages description in weblogic-applicatino.xml which detail is of package to be loaded from application.

<prefer-application-packages>  
<package-name>thirdparty package in your application which may be in weblogic</package-name>
</prefer-application-packages>

Installing CAT


CAT is a Web-based class analysis tool provided by weblogic and we need to deploy wls-cat.war which is located in “WL_HOME/server/lib/wls-cat.war”


After deploying it can be accessed in.


http://weblogichost:port/wls-cat/


CAT Display all currently running applications and modules.


You can use this tool to check Classloading conflicts , Check system and application classloaders and even generate report. For further information please refer to oracle documentation.


For me wls-cat.war is located in


image


I login to weblogic console


http://localhost:7101/console


image


Install war as application , not as lib.


image


Finally deployed with following context


image


Go to testing and access the application.


image


CAT TOOL GUI


image


We can use this “Analyze Conflict” , Generate Report etc.


image








Click analyze conflict. It showed me conflicting classes and gave me suggested solution that I can use in my weblogic-application.xml or weblogic.xml.


image

No comments:

Post a Comment