杰克逊错误:java.lang.NoClassDefFoundError:com/fasterxml/jackson/core/Versioned

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30783494/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 17:39:27  来源:igfitidea点击:

Hymanson error: java.lang.NoClassDefFoundError: com/fasterxml/Hymanson/core/Versioned

javajsonHymansonejb

提问by ???? ?? ??????

I am working on Maven-EJB and want to convert a java object to JSON, I use Hymanson jars lib but I got:

我正在研究 Maven-EJB 并想将 java 对象转换为 JSON,我使用 Hymanson jars lib,但我得到了:

java.lang.ClassNotFoundException: com.fasterxml.Hymanson.core.Versioned

java.lang.ClassNotFoundException: com.fasterxml.Hymanson.core.Versioned

I added these dependencies in pom.xml file:

我在 pom.xml 文件中添加了这些依赖项:

    <dependency>
        <groupId>com.fasterxml.Hymanson.core</groupId>
        <artifactId>Hymanson-databind</artifactId>
        <version>2.4.0</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.Hymanson.core</groupId>
        <artifactId>Hymanson-core</artifactId>
        <version>2.4.0</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.Hymanson.core</groupId>
        <artifactId>Hymanson-annotations</artifactId>
        <version>2.4.0</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.Hymanson.jaxrs</groupId>
        <artifactId>Hymanson-jaxrs-json-provider</artifactId>
        <version>2.4.0</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.Hymanson.module</groupId>
        <artifactId>Hymanson-module-jaxb-annotations</artifactId>
        <version>2.4.0</version>
    </dependency>        
</dependencies>
    <dependency>
        <groupId>com.fasterxml.Hymanson.core</groupId>
        <artifactId>Hymanson-databind</artifactId>
        <version>2.4.0</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.Hymanson.core</groupId>
        <artifactId>Hymanson-core</artifactId>
        <version>2.4.0</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.Hymanson.core</groupId>
        <artifactId>Hymanson-annotations</artifactId>
        <version>2.4.0</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.Hymanson.jaxrs</groupId>
        <artifactId>Hymanson-jaxrs-json-provider</artifactId>
        <version>2.4.0</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.Hymanson.module</groupId>
        <artifactId>Hymanson-module-jaxb-annotations</artifactId>
        <version>2.4.0</version>
    </dependency>        
</dependencies>

in Java Facade I write this lines to convert:

在 Java Facade 中,我写了以下几行来转换:

String json = "";

    try {
         ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
         json = ow.writeValueAsString(userlist);
    } catch (JsonProcessingException e) {
        throw new BusinessException("error_json");
    }

字符串 json = "";

    try {
         ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
         json = ow.writeValueAsString(userlist);
    } catch (JsonProcessingException e) {
        throw new BusinessException("error_json");
    }

and here is the imports:

这是进口:

import com.fasterxml.Hymanson.core.JsonProcessingException; import com.fasterxml.Hymanson.databind.ObjectMapper; import com.fasterxml.Hymanson.databind.ObjectWriter;

导入 com.fasterxml.Hymanson.core.JsonProcessingException; 导入 com.fasterxml.Hymanson.databind.ObjectMapper; 导入 com.fasterxml.Hymanson.databind.ObjectWriter;

I checked the classpath and make a lot of clean and build but no way,,,the same exception appear!!

我检查了类路径并进行了很多清理和构建,但没有办法,,出现相同的异常!!

I am working on NetBeans8 and Java 1.7

我正在研究 NetBeans8 和 Java 1.7

Thanks in advance Mariam

提前致谢

采纳答案by ???? ?? ??????

Thanks Couettos, it works, I checked the versions of application server and the maven jars then I downloaded the latest 2.4.0 Hymanson jars and upgrade the glassfish lib jars with the 2.4.0 version

谢谢 Couettos,它有效,我检查了应用程序服务器和 Maven jar 的版本,然后我下载了最新的 2.4.0 Hymanson jar 并使用 2.4.0 版本升级了 glassfish lib jar