Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoClassDefFoundError: org/apache/commons/lang3/Validate #847

Open
johno1985 opened this issue Apr 18, 2017 · 9 comments
Open

java.lang.NoClassDefFoundError: org/apache/commons/lang3/Validate #847

johno1985 opened this issue Apr 18, 2017 · 9 comments

Comments

@johno1985
Copy link

The following exception occurs when I tried running my first test using RestAssured version 3.0.2:

java.lang.NoClassDefFoundError: org/apache/commons/lang3/Validate
at io.restassured.config.LogConfig.(LogConfig.java:86)
at io.restassured.config.LogConfig.(LogConfig.java:45)
at io.restassured.config.RestAssuredConfig.(RestAssuredConfig.java:41)
at io.restassured.RestAssured.(RestAssured.java:420)
at com.launchworks.launchbi.it.cognos.ReportDataIT.returnOK(ReportDataIT.java:11)
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.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.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.Validate
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)
... 28 more

<dependency>
	<groupId>io.rest-assured</groupId>
	<artifactId>rest-assured</artifactId>
	<version>3.0.2</version>
	<scope>test</scope>
</dependency>
package com.mycomp.myproduct.it;

import static io.restassured.RestAssured.get;

import org.junit.Test;

public class ReportDataIT {

	@Test
	public void returnOK() {
		get("localhost:8080/Report/data").then().assertThat().statusCode(200);
	}
}
@johanhaleby
Copy link
Collaborator

I think there's something wrong with your classpath. You most likely haven't imported all REST Assured dependencies. See getting started guide.

@johno1985
Copy link
Author

johno1985 commented Apr 19, 2017 via email

@johanhaleby
Copy link
Collaborator

What do you mean by importing? There are indeed instructions that you should download all dependencies and put them in your classpath.

@johno1985
Copy link
Author

johno1985 commented Apr 19, 2017 via email

@johanhaleby
Copy link
Collaborator

Then there's something wrong with your maven configuration. You might be excluding commons-lang3 or it's overridden by some other transitive dependency. You could try to move rest-assured to the top of your libraries.

@johno1985
Copy link
Author

johno1985 commented Apr 19, 2017 via email

@johanhaleby
Copy link
Collaborator

That's very weird since the class you're referring to is available in org.apache.commons:commons-lang3:jar:3.4

@kobbikobb
Copy link

I tried exactly the code above and it worked.
This is very old and seems to be relevant to the setup of the machine.

Can we close this, can´t reproduce?

@jawadk
Copy link

jawadk commented Oct 11, 2019

As indicated on https://github.com/rest-assured/rest-assured/wiki/GettingStarted#java-9 you may add a dependency rest-assured-all.

<dependency>
   <groupId>io.rest-assured</groupId>
   <artifactId>rest-assured-all</artifactId>
   <version>4.0.0</version>
</dependency>

Add it SOLVED my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants