Hi,
I’m using gradle 1.11 and restassured 2.3.1 to do some web service test. And it is reporting exception like the following:
18:06:40.217 [DEBUG] [TestEventLogger] myproject.emceuas.ws.GeoLocationTest.setUp FAILED
18:06:40.218 [DEBUG] [TestEventLogger]
java.lang.NoSuchFieldError: DEF_CONTENT_CHARSET
18:06:40.218 [DEBUG] [TestEventLogger]
at com.jayway.restassured.config.EncoderConfig.(EncoderConfig.java:42)
18:06:40.218 [DEBUG] [TestEventLogger]
at com.jayway.restassured.config.RestAssuredConfig.(RestAssuredConfig.java:48)
18:06:40.218 [DEBUG] [TestEventLogger]
at com.jayway.restassured.RestAssured.(RestAssured.java:419)
18:06:40.218 [DEBUG] [TestEventLogger]
at myproject.emceuas.ws.GeoLocationTest.setUp(GeoLocationTest.java:36)
18:06:40.219 [DEBUG] [TestEventLogger]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
18:06:40.219 [DEBUG] [TestEventLogger]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
18:06:40.219 [DEBUG] [TestEventLogger]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
18:06:40.219 [DEBUG] [TestEventLogger]
at java.lang.reflect.Method.invoke(Method.java:601)
18:06:40.219 [DEBUG] [TestEventLogger]
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
18:06:40.219 [DEBUG] [TestEventLogger]
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:552)
18:06:40.219 [DEBUG] [TestEventLogger]
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:215)
18:06:40.219 [DEBUG] [TestEventLogger]
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:140)
18:06:40.219 [DEBUG] [TestEventLogger]
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:170)
18:06:40.220 [DEBUG] [TestEventLogger]
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:104)
18:06:40.220 [DEBUG] [TestEventLogger]
at org.testng.TestRunner.privateRun(TestRunner.java:767)
18:06:40.220 [DEBUG] [TestEventLogger]
at org.testng.TestRunner.run(TestRunner.java:617)
18:06:40.220 [DEBUG] [TestEventLogger]
at org.testng.SuiteRunner.runTest(SuiteRunner.java:348)
18:06:40.220 [DEBUG] [TestEventLogger]
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343)
18:06:40.220 [DEBUG] [TestEventLogger]
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305)
18:06:40.220 [DEBUG] [TestEventLogger]
at org.testng.SuiteRunner.run(SuiteRunner.java:254)
18:06:40.220 [DEBUG] [TestEventLogger]
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
18:06:40.220 [DEBUG] [TestEventLogger]
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
18:06:40.220 [DEBUG] [TestEventLogger]
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
18:06:40.220 [DEBUG] [TestEventLogger]
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
18:06:40.221 [DEBUG] [TestEventLogger]
at org.testng.TestNG.run(TestNG.java:1057)
18:06:40.221 [DEBUG] [TestEventLogger]
at org.gradle.api.internal.tasks.testing.testng.TestNGTestClassProcessor.stop(TestNGTestClassProcessor.java:112)
18:06:40.221 [DEBUG] [TestEventLogger]
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:59)
18:06:40.221 [DEBUG] [TestEventLogger]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
18:06:40.221 [DEBUG] [TestEventLogger]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
18:06:40.221 [DEBUG] [TestEventLogger]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
18:06:40.221 [DEBUG] [TestEventLogger]
at java.lang.reflect.Method.invoke(Method.java:601)
18:06:40.221 [DEBUG] [TestEventLogger]
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
18:06:40.221 [DEBUG] [TestEventLogger]
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
18:06:40.221 [DEBUG] [TestEventLogger]
at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
18:06:40.221 [DEBUG] [TestEventLogger]
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
18:06:40.222 [DEBUG] [TestEventLogger]
at $Proxy2.stop(Unknown Source)
18:06:40.222 [DEBUG] [TestEventLogger]
at org.gradle.api.internal.tasks.testing.worker.TestWorker.stop(TestWorker.java:115)
18:06:40.222 [DEBUG] [TestEventLogger]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
18:06:40.222 [DEBUG] [TestEventLogger]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
18:06:40.222 [DEBUG] [TestEventLogger]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
18:06:40.222 [DEBUG] [TestEventLogger]
at java.lang.reflect.Method.invoke(Method.java:601)
18:06:40.222 [DEBUG] [TestEventLogger]
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
18:06:40.222 [DEBUG] [TestEventLogger]
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
18:06:40.222 [DEBUG] [TestEventLogger]
at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:355)
18:06:40.222 [DEBUG] [TestEventLogger]
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
18:06:40.222 [DEBUG] [TestEventLogger]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
18:06:40.222 [DEBUG] [TestEventLogger]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
18:06:40.223 [DEBUG] [TestEventLogger]
at java.lang.Thread.run(Thread.java:722)
I searched by google with error message ’ java.lang.NoSuchFieldError: DEF_CONTENT_CHARSET’, the results indicate that this is caused by the version conflicting of httpclient jar file. From the log, I see several version httpclient, and gradle is doing the automatic selection between them:
Selected org.apache.httpcomponents:httpclient:4.2.5 from conflicting modules [org.apache.httpcomponents:httpclient:4.0.1, org.apache.httpcomponents:httpclient:4.2.5]
From the classpath I see there are two version of httpclient in two different classpath:
Using application classpath […
/scratch/xinhuan/gradle_user_home/caches/modules-2/files-2.1/org.apache.httpcomponents/httpclient/4.2.6/e4ca30a6a3a075053a61c6fc850d2432dc012ba7/httpclient-4.2.6.jar,
…]
Using implementation classpath […
file:/ade_autofs/ade_infra/nfsdo/GRADLE/1.11/GENERIC/140507.2150/gradle/lib/httpclient-4.2.2.jar,
…]
According to the error:
it indicates that the DEF_CONTENT_CHARSET is not found. Why is the httpclient jar file not found while it exists in the classpath?
There’s a similar thread in this forum, http://forums.gradle.org/gradle/topics/gradle1_11_wrapper_dependencies_conflict_with_project_dependencies The different is, in Berman’s scenario, he has two different version of httpcore jar files in the same classpath. I don’t see such situation, the two different version of httpclient jar files are included in two different classpath. I tried the way Berman mentioned, and have no luck yet.
Thanks, Xin
Thanks,
Xin