java.lang.NoSuchMethodError:org.codehaus.jackson.map.AnnotationIntrospector.pair

时间:2015-07-27 09:28:56

标签: maven jax-rs apache-drill

我正在尝试使用JAX RS服务。我在我的pom .xml中添加了一些依赖项。这是pom。

    <properties>
    <jersey.version>1.19</jersey.version>
</properties>
<dependencies>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-servlet</artifactId>
        <version>${jersey.version}</version>
    </dependency>

    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-json</artifactId>
        <version>${jersey.version}</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-client</artifactId>
        <version>${jersey.version}</version>
    </dependency>


    <dependency>
        <groupId>org.mvel</groupId>
        <artifactId>mvel2</artifactId>
        <version>2.2.1.Final</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.0</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.2.4</version>
    </dependency>

    <dependency>
        <groupId>org.apache.drill.exec</groupId>
        <artifactId>drill-jdbc-all</artifactId>
        <version>1.1.0</version>
    </dependency>

</dependencies>

当我添加此依赖项<dependency> <groupId>org.apache.drill.exec</groupId> <artifactId>drill-jdbc-all</artifactId> <version>1.1.0</version> </dependency>时 它失败了elow提到的例外。我需要上面提到的apache drill依赖。在移除和运行时,它工作顺利。

我得到的是:

java.lang.NoSuchMethodError: org.codehaus.jackson.map.AnnotationIntrospector.pair(Lorg/codehaus/jackson/map/AnnotationIn
trospector;Lorg/codehaus/jackson/map/AnnotationIntrospector;)Lorg/codehaus/jackson/map/AnnotationIntrospector;
    at org.codehaus.jackson.jaxrs.MapperConfigurator._resolveIntrospectors(MapperConfigurator.java:155)
    at org.codehaus.jackson.jaxrs.MapperConfigurator._setAnnotations(MapperConfigurator.java:133)
    at org.codehaus.jackson.jaxrs.MapperConfigurator.getDefaultMapper(MapperConfigurator.java:70)
    at org.codehaus.jackson.jaxrs.JacksonJsonProvider.locateMapper(JacksonJsonProvider.java:648)
    at org.codehaus.jackson.jaxrs.JacksonJsonProvider.writeTo(JacksonJsonProvider.java:500)
    at com.sun.jersey.json.impl.provider.entity.JacksonProviderProxy.writeTo(JacksonProviderProxy.java:160)
    at com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:302)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1510)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)
    at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291).

可以请一些人帮忙,因为在添加特定依赖项时,为什么失败并带有上述异常。

尝试运行mvn依赖树来检查jar中的冲突。

构建JAXRS-JSON Maven Webapp 0.0.1-SNAPSHOT

------------------------------------------------------------------------

 --- maven-dependency-plugin:2.8:tree (default-cli) @ JAXRS-JSON ---
 com.java.codegeeks.example:JAXRS-JSON:war:0.0.1-SNAPSHOT
 +- com.sun.jersey:jersey-servlet:jar:1.19:compile
 |  \- com.sun.jersey:jersey-server:jar:1.19:compile
 +- com.sun.jersey:jersey-json:jar:1.19:compile
 |  +- org.codehaus.jettison:jettison:jar:1.1:compile
 |  +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile
 |  |  \- javax.xml.bind:jaxb-api:jar:2.2.2:compile
 |  |     +- javax.xml.stream:stax-api:jar:1.0-2:compile
 |  |     \- javax.activation:activation:jar:1.1:compile
 |  +- org.codehaus.jackson:jackson-core-asl:jar:1.9.2:compile
 |  +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:compile
 |  +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.2:compile
 |  +- org.codehaus.jackson:jackson-xc:jar:1.9.2:compile
 |  \- com.sun.jersey:jersey-core:jar:1.19:compile
 |     \- javax.ws.rs:jsr311-api:jar:1.1.1:compile
 +- com.sun.jersey:jersey-client:jar:1.19:compile
 +- junit:junit:jar:3.8.1:test
 \- org.apache.drill.exec:drill-jdbc-all:jar:1.1.0:compile
 ------------------------------------------------------------------------
 BUILD SUCCESS

1 个答案:

答案 0 :(得分:0)

钻包含太多的包,它与app中的其他jar相撞。我也遇到过类似的问题,但是使用了钻头jar的com.google.common.collect和org.apache.zookeeper包。在我的情况下,版本钻取用于这些包较旧,所以,我刚删除它们。

zip -d drill-jdbc-all-1.1.0.jar com/google/common/collect/*
zip -d drill-jdbc-all-1.1.0.jar org/apache/zookeeper/*

现在工作正常。我不知道如何使用maven处理所有这些,因此选择删除。如果maven可以处理它会更好。