discuss: classloader hierarchy to solve JAR dependency hell?

Scenario:

You want to use two ibraries A and B that depend on a certain library C. C has different versions, say V.1 and V.2.

Library A depends on the new version V.2 of C and calls newly-added methods, and B depends on the old version V.1 of C and calls deprecated methods that have been removed in V.2.

Now we're in dependency hell. We can't use both versions of C the same time.

Idea:

Create a classloader hierarchy, where A and B get their own classloaders.

Global Classloader (loads other libs)

|

|- Classloader for library A (loads V.2 of C)

|- Classloader for library B (loads V.1 of C)

Let the classloader for library A load V.2 of C and the classloader for B load V.1 of C. All other classes are loaded by the global classloader.

A class should be looked up in the "library classloaders" first, and when not found there, in the "global classloader". That way, each library could gets its required version of the library without causing library confilcts.

How do you like the suggested idea?

Do you think this is possible or know of an implementation or similar solution of the problem, especially for web containers?

Best regards,

Sebastian

[1249 byte] By [SMittelstaedta] at [2007-11-26 22:09:15]
# 1

> How do you like the suggested idea?

I like it. I like it a lot (what movie was that from?)

No seriously, I do like this idea but it needs to be fleshed out. Before this is possible you would need to have complete black box isolation for different classloaders.

What happens if you make a C in A, then a C variable using B's definition, and you try to assign the value you've created to the other area? How are you going to distinguish between the two versions of this class? And how are you going to prevent namespace clash?

> Do you think this is possible or know of an

> implementation or similar solution of the problem,

> especially for web containers?

>

>

> Best regards,

>

> Sebastian

tjacobs01a at 2007-7-10 10:55:50 > top of Java-index,Desktop,Deploying...