ciplogic.com
Live with grace. Write superb software.

So here's the problem.

You have a webapp that packs two jars A.jar, and B.jar. A depends on C.v1.jar, but B depends on C.v2.jar. Both C jars include the same class with different signatures, because they are different, incompatible, versions.

I can hear you sighing from here.

There are actually a few solutions:

1. OSGI. If you can figure it out, it can actually do the classloader magic for you.

2. If you're like me you can use the WEB-INF/classes, since these classes are loaded in a classloader that has priority over WEB-INF/lib classes, and attempt to do via sources, or a decompiler (JD-GUI) a  conflicting class that is compatible with both A and B. But that's error prone, and is a LOT of work, for more complex changes in API.

3. JarJar. With JarJar you can rename a package to another package, and it will also rename all the references in the classes. So you can just pick for example B and C.v2.jar, and rename the conflicting packages or classes (directly inside the jar themselves).

4. Project JigSaw, seems to be adressing just that, but this appears to be available only with Java 8 unfortunately.

Personally I used JarJar. Seemed by far the easiest to use, and worked flawlessly.

Disqus Comments

comments powered by Disqus

Germanium

The one to rule them all. The browsers that is.

SharpKnight

SharpKnight is an Android chess game.

MagicGroup

MagicGroup is an eclipse plugin.