java.lang.NoClassDefFoundError trying to find org.apache.http.config.Lookup

2,509 views
Skip to first unread message

Charles

unread,
Nov 8, 2016, 12:34:53 AM11/8/16
to REST assured
Environment: Eclipse IDE (v.Neon), TestNG (6.9.4), Maven (3.0.4), RestAssured(3.0.1), Win7

Given the following:

    private RequestSpecification given(){
        return RestAssured.given();
    }
    @Test
    public void testRestAssured(/*String unitId*/) {
      given().
        accept("application/json").
      when().
        get("http://ip.jsontest.com/?callback=showMyIP").//Line 71
      then()....
  }

I receive the following when trying to run the test, in combination or on its own:
java.lang.NoClassDefFoundError: org/apache/http/config/Lookup
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
    at java.lang.Class.privateGetPublicMethods(Unknown Source)
    at java.lang.Class.getMethods(Unknown Source)
    at java.beans.Introspector.getPublicDeclaredMethods(Unknown Source)
    at java.beans.Introspector.getTargetMethodInfo(Unknown Source)
    at java.beans.Introspector.getBeanInfo(Unknown Source)
    at java.beans.Introspector.getBeanInfo(Unknown Source)
    at java.beans.Introspector.getBeanInfo(Unknown Source)
    at java.beans.Introspector.<init>(Unknown Source)
    at java.beans.Introspector.getBeanInfo(Unknown Source)
    at groovy.lang.MetaClassImpl$15.run(MetaClassImpl.java:3289)
    at java.security.AccessController.doPrivileged(Native Method)
    at groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:3287)
    at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:3263)
    at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:254)
    at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:285)
    at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:295)
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:261)
    at org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(InvokerHelper.java:877)
    at org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:910)
    at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:902)
    at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToBoolean(DefaultTypeTransformation.java:185)
    at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.booleanUnbox(DefaultTypeTransformation.java:74)
    at io.restassured.internal.RequestSpecificationImpl.sendRequest(RequestSpecificationImpl.groovy:1165)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1212)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1021)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:812)
    at io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)
    at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:149)
    at io.restassured.internal.filter.SendRequestFilter.filter(SendRequestFilter.groovy:30)
    at io.restassured.filter.Filter$filter$0.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at io.restassured.filter.Filter$filter.call(Unknown Source)
    at io.restassured.internal.filter.FilterContextImpl.next(FilterContextImpl.groovy:72)
    at io.restassured.filter.time.TimingFilter.filter(TimingFilter.java:56)
    at io.restassured.filter.Filter$filter.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at io.restassured.filter.Filter$filter$0.call(Unknown Source)
    at io.restassured.internal.filter.FilterContextImpl.next(FilterContextImpl.groovy:72)
    at io.restassured.filter.FilterContext$next.call(Unknown Source)
    at io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1638)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1212)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1021)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:812)
    at io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)
    at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:48)
    at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:58)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182)
    at io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1644)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1212)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1021)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:812)
    at io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)
    at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:48)
    at org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:58)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182)
    at io.restassured.internal.RequestSpecificationImpl.get(RequestSpecificationImpl.groovy:167)
    at io.restassured.internal.RequestSpecificationImpl.get(RequestSpecificationImpl.groovy)
    at idx.restassured.App.testRestAssured(App.java:71)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:659)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:845)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1153)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
    at org.testng.TestRunner.privateRun(TestRunner.java:771)
    at org.testng.TestRunner.run(TestRunner.java:621)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
    at org.testng.SuiteRunner.run(SuiteRunner.java:259)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1199)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1124)
    at org.testng.TestNG.run(TestNG.java:1032)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:152)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:57)
Caused by: java.lang.ClassNotFoundException: org.apache.http.config.Lookup
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 115 more

I have used the maven dependency checker to find the failing Lookup dependency, but it does not list it.
I have searched the RestAssured GitHub repo for Lookup, with no success.
There is no entry of org.apache... at all.
I have changed test URLs, and initialized baseURLs and other defaults I found, to no avail.

I am not sure what to do.
When I run mvn clean install I receive the following:
$ mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building app 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ rest-testing ---
[INFO] Deleting C:\Users\cemcelwee\workspace\restAssured\target
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ rest-testing ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\cemcelwee\workspace\restAssured\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ rest-testing ---
[INFO] Compiling 1 source file to C:\Users\cemcelwee\workspace\restAssured\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] idx\restassured\App.java:[3,21] error: package io.restassured does not exist
[ERROR] idx\restassured\App.java:[4,0] error: package io.restassured.RestAssured does not exist
[ERROR] idx\restassured\App.java:[5,26] error: package io.restassured.http does not exist
[ERROR] idx\restassured\App.java:[6,0] error: package io.restassured.matcher.RestAssuredMatchers does not exist
[ERROR] idx\restassured\App.java:[8,19] error: package org.hamcrest does not exist
[ERROR] idx\restassured\App.java:[9,0] error: package org.hamcrest.Matchers does not exist
[ERROR] idx\restassured\App.java:[10,15] error: package org.json does not exist
[ERROR] idx\restassured\App.java:[11,15] error: package org.json does not exist
[ERROR] idx\restassured\App.java:[13,0] error: package io.restassured.module.jsv.JsonSchemaValidator does not exist
[ERROR] idx\restassured\App.java:[14,30] error: package io.restassured.response does not exist
[ERROR] idx\restassured\App.java:[15,35] error: package io.restassured.specification does not exist
[ERROR] idx\restassured\App.java:[30,32] error: package com.sun.jersey.api.client does not exist
[ERROR] idx\restassured\App.java:[61,9] error: cannot find symbol
[ERROR] idx\restassured\App.java:[64,15] error: cannot find symbol
[ERROR] idx\restassured\App.java:[87,72] error: cannot find symbol
[ERROR] idx\restassured\App.java:[43,5] error: cannot find symbol
[ERROR] idx\restassured\App.java:[44,5] error: cannot find symbol
[ERROR] idx\restassured\App.java:[49,8] error: cannot find symbol
[ERROR] idx\restassured\App.java:[52,7] error: cannot find symbol
[ERROR] idx\restassured\App.java:[53,7] error: cannot find symbol
[ERROR] idx\restassured\App.java:[62,9] error: cannot find symbol
[ERROR] idx\restassured\App.java:[64,31] error: cannot find symbol
[ERROR] idx\restassured\App.java:[78,17] error: cannot find symbol
[ERROR] idx\restassured\App.java:[79,23] error: cannot find symbol
[ERROR] idx\restassured\App.java:[80,23] error: cannot find symbol
[ERROR] idx\restassured\App.java:[81,31] error: cannot find symbol
[ERROR] idx\restassured\App.java:[75,21] error: cannot find symbol
[ERROR] idx\restassured\App.java:[94,5] error: cannot find symbol
[ERROR] idx\restassured\App.java:[94,27] error: cannot find symbol
[INFO] 29 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.918s
[INFO] Finished at: Mon Nov 07 13:50:13 MST 2016
[INFO] Final Memory: 13M/304M


These errors are for these includes, which, for some reason, the IDE does not completely understand, though I can use the components' static calls (hence the initial method at the very top of this message):
import io.restassured.RestAssured;
import io.restassured.RestAssured.*;
import io.restassured.http.ContentType;
import io.restassured.matcher.RestAssuredMatchers.*;

import org.hamcrest.Matchers;
import org.hamcrest.Matchers.*;
import org.json.JSONException;
import org.json.JSONObject;

import io.restassured.module.jsv.JsonSchemaValidator.*;
import io.restassured.response.Response;
import io.restassured.specification.RequestSpecification;
import javafx.beans.binding.When;

import org.testng.Assert;
import org.testng.ITestResult;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import com.sun.jersey.api.client.Client;


I obviously have something (or everything) configured incorrectly, but I have no idea how to proceed.
I am investigating RestAssured, and obviously cannot proceed without being able to make a .get() call.

Any help is greatly appreciated.

Johan Haleby

unread,
Nov 8, 2016, 1:34:23 AM11/8/16
to rest-a...@googlegroups.com
You're probably missing a dependency or have conflicting versions of apache http client in your classpath. The easiest way is to use Maven or Gradle.

--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Charles

unread,
Nov 10, 2016, 2:01:19 PM11/10/16
to REST assured
I am using Maven version 3.0.4, along with the other software I listed on the first line of my question. As I stated further along in my post I also used the Maven dependency tree to see where this dependency could reside, and it is not listed.

Thanks for your response anyway.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.

Johan Haleby

unread,
Nov 14, 2016, 1:50:08 AM11/14/16
to rest-a...@googlegroups.com
Here you can see an excerpt of the classpath:

[INFO] +- io.rest-assured:rest-assured:jar:3.0.2-SNAPSHOT:compile
[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] |  +- org.apache.httpcomponents:httpmime:jar:4.5.1: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] +- io.rest-assured:json-schema-validator:jar:3.0.2-SNAPSHOT:compile
[INFO] |  \- com.github.fge:json-schema-validator:jar:2.2.6:compile
[INFO] |     +- com.google.code.findbugs:jsr305:jar:3.0.0:compile
[INFO] |     +- com.googlecode.libphonenumber:libphonenumber:jar:6.2:compile
[INFO] |     +- com.github.fge:json-schema-core:jar:1.2.5:compile
[INFO] |     |  +- com.github.fge:uri-template:jar:0.9:compile
[INFO] |     |  |  \- com.github.fge:msg-simple:jar:1.1:compile



To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured+unsubscribe@googlegroups.com.

Charles McElwee

unread,
Nov 14, 2016, 1:15:13 PM11/14/16
to rest-a...@googlegroups.com
I did indeed see that particular classpath, however, it is worth noting that there are many org.apache classes in the dependency tree and there was no way for me to verify if the failing path (e.g. org/apache/http/config/Lookup) was in any one of them. Perhaps the http/config/Lookup class actually compiles into a path that doesn't match its own path, but that doesn't make a whole lot of sense to me.

--
You received this message because you are subscribed to a topic in the Google Groups "REST assured" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rest-assured/zqDf8-X37vQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rest-assured+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages