|Duplicate classes when using maven weave dependencies [message #1050023]
||Fri, 26 April 2013 11:34
| Rudi Vankeirsbilck
Registered: April 2013
My project consists of a number of modules, say module A and B and classes from module A have advice defined in aspects from module B. The advice is call, execution and inter type advice. I quickly found that I can add <weaveDependencies> in my pom file to get this working.|
This has been working for quite some time now and we have started to look at assembling the project into a working set of deployable components. We discovered that the weave dependencies have a side effect that the classes from module A that have execution and inter type advice in module B are actually recompiled in the target directory of module B. so A/target/classes contains SomeClass.class and B/target/classes also contains a SomeClass.class. The first is the original compiled class, the latter is the one that has the advice.
When simply bundling all the JARs together and constructing a classpath from that, we find at runtime two different versions of SomeClass and depending on the order of the class path it will sometimes be the one that contains the advice and sometimes the one without the advice.
The problem is even worse when SomeClass implement an interface SomeInterface. In that case, SomeInterface is also duplicated in B's target directory. The same applies to exception classes that on the method signatures of SomeInterface or SomeClass.
I was wondering how this problem is typically tackled? How do I safely remove all duplicates from the constructed JARs or is it recommended to hardcode the classpath order such that B.jar is always before A.jar and therefore the VM will always load the classes with the advice?
Powered by FUDForum
. Page generated in 0.01959 seconds