java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformer

匿名 (未验证) 提交于 2019-12-03 01:19:01

问题:

I am receiving the following error java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformer trying to use BeanMap from the Apache Commons BeanUtils library.

It is generated from the following code: BeanMap studentBeanMap = new BeanMap(cohortStudentData.get(row)); where cohortStudentData is a list of beans.

I am using BeanListHandler from Apache DBUtils to form the list of beans from a database.

I understand from this and this bug report that BeanMap is dependant on the Apache Collections framework. However, I have imported all relevant libraries into my project and into my class, as you can see below:

Does anyone know why this might be happening?

回答1:

I am not really sure, but i think your error is because of jar versions. Lately apache has changed the package of the new versions of their jars because they implement new functionality or something that is not fully backward compatible. For example the jar commons-beanutils-1.9.2.jar depends on commons-collections-3.2.1.jar (according to this site) and you are using commons-collections-4.4.0.jar. If you are planning using the universe of apache jars, you need to be sure that they are all compatible.



回答2:

Just add this dependency to your project.

    commons-collectionscommons-collections3.2.2


回答3:

commons-collections4-x.x.jar Add the library to your classpath and try to run again. It will work.

Download the library from: https://mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.1



回答4:

Adding dependency of version 3.2.1 seems working here

commons-collectionscommons-collections3.2.1


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!