简体   繁体   English

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

[英]java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformer

I am receiving the following error java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformer trying to use BeanMap from the Apache Commons BeanUtils library.我收到以下错误java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformer试图使用 Apache Commons BeanUtils 库中的BeanMap

It is generated from the following code: BeanMap studentBeanMap = new BeanMap(cohortStudentData.get(row));它由以下代码生成: BeanMap studentBeanMap = new BeanMap(cohortStudentData.get(row)); where cohortStudentData is a list of beans.其中cohortStudentData是一个 bean 列表。

I am using BeanListHandler from Apache DBUtils to form the list of beans from a database.我正在使用 Apache DBUtils 中的BeanListHandler从数据库中形成 bean 列表。

I understand from this and this bug report that BeanMap is dependant on the Apache Collections framework.我从这个这个错误报告中了解到BeanMap依赖于 Apache Collections 框架。 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?有谁知道为什么会发生这种情况?

I am not really sure, but i think your error is because of jar versions.我不太确定,但我认为您的错误是因为 jar 版本。 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.最近 apache 更改了新版本 jars 的包,因为它们实现了新功能或不完全向后兼容的东西。 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.例如,jar commons-beanutils-1.9.2.jar 依赖于 commons-collections-3.2.1.jar(根据网站),而您使用的是 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.如果您计划使用 apache jar 的世界,您需要确保它们都是兼容的。

Just add this dependency to your project.只需将此依赖项添加到您的项目中即可。

    <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>3.2.2</version>
    </dependency>

commons-collections4-xxjar Add the library to your classpath and try to run again. commons-collections4-xxjar将库添加到您的类路径并尝试再次运行。 It will work.它会起作用。

Download the library from: https://mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.1从以下位置下载库: https : //mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.1

Adding dependency of version 3.2.1 seems working here添加版本 3.2.1 的依赖似乎在这里工作

<dependency>
    <groupId>commons-collections</groupId>
    <artifactId>commons-collections</artifactId>
    <version>3.2.1</version>
</dependency>

将 commons-collections-3.2.jar 添加到项目库中

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.NoClassDefFoundError: org/apache/commons/collections/map/LRUMap - java.lang.NoClassDefFoundError: org/apache/commons/collections/map/LRUMap 休眠java.lang.NoClassDefFoundError:org / apache / commons / collections / MultiMap - Hibernate java.lang.NoClassDefFoundError: org/apache/commons/collections/MultiMap java.lang.NoClassDefFoundError:org / apache / commons / collections / ReferenceMap - java.lang.NoClassDefFoundError: org/apache/commons/collections/ReferenceMap 错误:java.lang.NoClassDefFoundError:org / apache / commons / collections / map / LRUMap - Error : java.lang.NoClassDefFoundError: org/apache/commons/collections/map/LRUMap java.lang.NoClassDefFoundError:org / apache / commons / lang / text / StrLookup - java.lang.NoClassDefFoundError: org/apache/commons/lang/text/StrLookup java.lang.NoClassDefFoundError: org/apache/commons/lang/builder/CompareToBuilder - java.lang.NoClassDefFoundError: org/apache/commons/lang/builder/CompareToBuilder java.lang.NoClassDefFoundError:org.apache.commons.lang3.ArrayUtils - java.lang.NoClassDefFoundError: org.apache.commons.lang3.ArrayUtils java.lang.NoClassDefFoundError:org / apache / commons / lang / Validate - java.lang.NoClassDefFoundError: org/apache/commons/lang/Validate java.lang.NoClassDefFoundError:org / apache / commons / lang3 / ObjectUtils - java.lang.NoClassDefFoundError: org/apache/commons/lang3/ObjectUtils java.lang.NoClassDefFoundError:Lorg / apache / commons / collections / FastHashMap; - java.lang.NoClassDefFoundError: Lorg/apache/commons/collections/FastHashMap;
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM