【问题标题】:Rest Assured - java.lang.NoSuchFieldError: DEF_CONTENT_CHARSET放心 - java.lang.NoSuchFieldError: DEF_CONTENT_CHARSET
【发布时间】:2016-10-21 16:42:34
【问题描述】:

测试过去直到上周才通过,现在开始失败。错误如下所示。

放心=2.9.0 httpclient-4.5.1.jar httpcore-4.4.3.jar

我从 ivy 中排除了其他 httpclient 和 core jars 这两个版本来自放心。请我真的需要帮助。

import static com.jayway.restassured.RestAssured.given
@Test
public void getSummary(){
given().
contentType("application/json").
when().
get("http://example.org/ab/resources/client/case/123455").
then().
statusCode(200).
extract().path("id");
;

//statusCode(200);

}

java.lang.NoSuchFieldError: DEF_CONTENT_CHARSET
at com.jayway.restassured.config.EncoderConfig.(EncoderConfig.java:61)
at com.jayway.restassured.config.RestAssuredConfig.(RestAssuredConfig.java:41)
at com.jayway.restassured.RestAssured.(RestAssured.java:423)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:278)
at org.codehaus.groovy.runtime.callsite.CallSiteArray$1.run(CallSiteArray.java:68)
at org.codehaus.groovy.runtime.callsite.CallSiteArray$1.run(CallSiteArray.java:65)
at java.security.AccessController.doPrivileged(Native Method)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallStaticSite(CallSiteArray.java:65)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:198)
at com.thomson.tssq.jwb.restapitests.RestAPITest.getSummary(RestAPITest.groovy:16)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

【问题讨论】:

标签: rest-assured


【解决方案1】:

查看您在类路径或 maven pom.xml 中是否有下面列出的 jar

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ rest-assured ---
[INFO] io.rest-assured:rest-assured:jar:3.0.2-SNAPSHOT
[INFO] +- org.codehaus.groovy:groovy:jar:2.4.6:compile
[INFO] +- org.codehaus.groovy:groovy-xml:jar:2.4.6:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.5.2:compile
[INFO] |  +- org.apache.httpcomponents:httpcore:jar:4.4.4:compile
[INFO] |  +- commons-logging:commons-logging:jar:1.2:compile
[INFO] |  \- commons-codec:commons-codec:jar:1.9:compile
[INFO] +- org.apache.httpcomponents:httpmime:jar:4.5.1:compile
[INFO] +- com.github.scribejava:scribejava-apis:jar:2.5.3:compile
[INFO] |  \- com.github.scribejava:scribejava-core:jar:2.5.3:compile
[INFO] +- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] +- org.hamcrest:hamcrest-library:jar:1.3:compile
[INFO] +- org.ccil.cowan.tagsoup:tagsoup:jar:1.2.1:compile
[INFO] +- io.rest-assured:json-path:jar:3.0.2-SNAPSHOT:compile
[INFO] |  +- org.codehaus.groovy:groovy-json:jar:2.4.6:compile
[INFO] |  \- io.rest-assured:rest-assured-common:jar:3.0.2-SNAPSHOT:compile
[INFO] +- io.rest-assured:xml-path:jar:3.0.2-SNAPSHOT:compile
[INFO] |  \- org.apache.commons:commons-lang3:jar:3.4:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.7.3:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.7.0:compile
[INFO] |  \- com.fasterxml.jackson.core:jackson-core:jar:2.7.3:compile
[INFO] +- org.codehaus.jackson:jackson-core-asl:jar:1.9.11:compile
[INFO] +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.11:compile
[INFO] +- com.google.code.gson:gson:jar:2.6.2:compile
[INFO] +- com.googlecode.json-simple:json-simple:jar:1.1.1:compile
[INFO] +- junit:junit:jar:4.12:test
[INFO] \- org.assertj:assertj-core:jar:1.7.0:test

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-10
    • 2013-06-05
    • 2013-01-04
    • 2020-04-11
    相关资源
    最近更新 更多