I am currently working on a very large project that currently consists of 25 modules. We where having a lot of exceptions being thrown around so I decided to search for a solution.
I discovered that our application that is one of the modules had a very long list of jar files in the lib directory that should not be there. A lot of jar files where duplicates. We had three different versions of commons-collections and two different version of command-lang. This could have been the cause of all our problems. I solved this by adding excludes to the dependencies that provided older versions of the jar files. To find the culprit dependency took a lot of searching in pom files (local in the project or remote on our maven proxy). We used commons-cli to parse the incoming arguments this provided a very old version of commons-collections and commons-lang.
The original dependency is as follows:
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
And I changed it to:
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.0</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
This solved our duplicated jar files problem.
On to the next problem. In our web module called frontend we had a jar file called: asm-2.2.jar. We also are using Hibernate in our project but it depended on asm-1.5.3.jar and the versions are NOT compatible. It gave us ClassNotFoundExceptions.
After some searching I discovered that the newer version of the jar came from a dependency on groovy. Groovy was included as runtime dependency for our struts (1.3.5) scripting part of the application. I tried to use the same solution as I did with the previous problem but that did not work.
The dependencies within out project might be a bit complex; below is the persistence part of our application:
project
|
+--persistence
|
+--persistence-util
|
+--Hibernate
|
+--asm(1.5.3)
|
+--cglib
| |
| +--asm(1.5.3)
|
+--(others)
In our frontend project we have a dependency on the persistence module and on groovy. Groovy in his turn is dependent on asm-2.2.jar. When we exclude the asm library from the transitive dependency in the groovy dependency maven removes them all!
The only solution we could find was to remove the groovy library as scripting facility all together. It seemed that the application run fine without it anyway 