Package ClassLoader-Jar Load Sequencing

Greeting,

I am placeing a.jar and b.jar under ./packages/mypackage/code/jars/ folder

b.jar contains newer version of classes in a.jar.
When I run my java service I wish to load b.jar first in classpath so that newer version of classes are picked always.

I am bound by following restriction

  1. I can’t keep one version of class in jars or class folder due to our roll out
    process
  2. I cannot set classpath in server.bat as the jars loaded in server.bat
    cannot be reloaded without recycling the server but defining the load
    sequence at package level can reload the latest jars if package is reloaded

Would appreciate your help.
Thanks,
Puneet

Did you try renaming the newer jars in reverse alphabetical order?

For ex: in your build script, change logic to name the customjar with the following convention customjar<99999999-YYYYMMDD>.jar

So, the older jar from 2006-12-05 would be named as customjar79938794.jar
And, the newer jar from 2007-01-23 would be named as customjar79929876.jar

I think this would solve your problem. Remember the logic to name the jar is given to illustrate the solution better. Choose logic which suits your needs.

Does this help or did I get your question wrong?

  • Saurabh