Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

duplicate classes in commons-collections and commons-beanutils

There are four duplicate classes in two Maven artifacts from Apache: commons-beanutils:commons-beanutils:1.8.3 and commons-collections:commons-collections:3.2.1:

org.apache.commons.collections.ArrayStack
org.apache.commons.collections.Buffer
org.apache.commons.collections.BufferUnderflowException
org.apache.commons.collections.FastHashMap

Is it possible to replace one of them with some other artifact to avoid this duplication? I tried to google but didn't find any solution. Rather annoying problem.

like image 232
yegor256 Avatar asked Jan 18 '13 16:01

yegor256


People also ask

What is Commons collections used for?

Commons Collections was introduced as a series of utilities that augment the Java Collections API. Commons Collections contains functors such as Predicate and Closure , utilities for filtering and selecting elements in a collection, and some new collections: Bag and Buffer .

What is Commons collections4?

Commons Collections augments Java Collections Framework. It provides several features to make collection handling easy. It provides many new interfaces, implementations and utilities.


1 Answers

In this case, the problem isn't maven or exclusions (which usually is the issue) but you are using the wrong version of beanutils most likely.

There is a version of the beanutils jar that has bean collections included and one that does not. The maven dependencies for the beanutils with bean collections includes commons collections. If you are using commons collections yourself, use the core version of and include commons collections in the maven dependencies.

This is where it is explained a bit: http://commons.apache.org/beanutils/

That page says this:

commons-beanutils.jar - contains everything
commons-beanutils-core.jar - excludes Bean Collections classes
commons-beanutils-bean-collections.jar - only Bean Collections classes

The main commons-beanutils.jar has an optional dependency on Commons Collections
like image 136
Lee Meador Avatar answered Oct 03 '22 20:10

Lee Meador