ATG-Class-Path Usage and Duplicate Class Files in JARS

I came across a situation in which i have two Class Files of the same name in different JARs but with some methods similar and other methods entirely different , these two JARS are required for the same Project with different Modules and i want to access the one which is compatible with my Code and Module,The other Module obviously dont want this Class file but requires other Classes,now the issue is you  have both the jars in CLASSPATH.How will you make sure you are pointing to the correct Class files in this situation, you need the Class Files from one JAR which has your updated method for a new functionality,

You may experience the same issue while organizing imports or resolving a Java component.

Here you need to do two things,first one is to resolve the component at Compile time in Eclipse or other IDEs,the second part is to resolve the runtime conflicts in the Application Server

So for Compile time,Assume if you are using Eclipse and you have both  JAR added to your build path ,you need to go to "Order and Export" tab and move your  updated jar above the other one,after this  you may able to build your Project smoothly without any issues.Second is to resolve the runtime conflicts

ATG has provided a beautiful way of handling this scenario,we have in ATG a better way of loading the CLASSPATHS,ATG looks for  MANIFEST.MF file,this file will specify which oder your Application Server has to load the CLASSPATHs.So put your updated JAR files before the other one in this Property.

Below is the example

ATG-Class-Path: lib/updated.jar lib/old.jar

Here its generally not that tough to resolve the issue by either finding the Class and the dependant Files , but there are situations in which we might face the similiar issues in OOTB Classes of different Vendors which need to be resolved.So this will be a good reference for the Beginners.

MANIFEST.MF
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.0
Created-By: 16.0-b13 (Sun Microsystems Inc.)
ATG-Product: The Commerce Reference Store
ATG-Class-Path: classes lib/
lib/updated.jar lib/old.jar
ATG-Config-Path: config
ATG-Required:Store.EStore

After Configuring the Manifest File and Deploying the Application you can verify the Application Server Startup logs.You may see the updated.jar will be loaded first then the old.jar will be loaded.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...