How to solve: Exception in thread "main" java.lang.NoClassDefFoundError: io/restassured/RestAssured ?
Exception in thread "main" java.lang.NoClassDefFoundError: io/restassured/RestAssured
Just Change Scope : Test --> Compile for rest-assured artifact in POM.xml
Before:
<!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>3.1.0</version>
<scope>test</scope>
</dependency>
After:
<!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>3.1.0</version>
<scope>compile</scope>
</dependency>
Just Change Scope : Test --> Compile for rest-assured artifact in POM.xml
Before:
<!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>3.1.0</version>
<scope>test</scope>
</dependency>
After:
<!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>3.1.0</version>
<scope>compile</scope>
</dependency>
Thanks a lot .. It solved my problem..
ReplyDeleteU're Welcome :)
DeleteHi Ishan, I was facing the same issue google it with couple different queries and later on i found your post which resolved my issue. Thank you very much dude :) !!
DeleteWelcome Dear :)
DeleteI am facing same issue but i am not using POM.Can anyone please help me in this?
ReplyDeleteDownload and downgrade Rest-Assured Jar to version 3.1.0. Rebuild the project. It should get fixed.
Deletethis is error which is shown
ReplyDeleteC:\Users\Daffolap-624\workspace\WapandaParallel1>java org.testng.TestNG -log 10 C:\Users\Daffolap-624\workspace\WapandaParallel1\testng.xml
[TestNG] RUNNING: Suite: "Test" containing "1" Tests (config: C:\Users\Daffolap-624\workspace\WapandaParallel1\testng.xml)
[TestNG] INVOKING CONFIGURATION: "Test" - @BeforeTest API_Automation.ApiOperationsTest.StartDriver()
[TestNG] FAILED CONFIGURATION: "Test" - @BeforeTest API_Automation.ApiOperationsTest.StartDriver() finished in 13 ms
[TestNG] java.lang.NoClassDefFoundError: io/restassured/RestAssured
[TestNG] at API_Automation.ApiOperationsTest.StartDriver(ApiOperationsTest.java:36)
[TestNG] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[TestNG] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[TestNG] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[TestNG] at java.lang.reflect.Method.invoke(Unknown Source)
[TestNG] at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
[TestNG] at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:523)
[TestNG] at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:224)
[TestNG] at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:146)
[TestNG] at org.testng.TestRunner.beforeRun(TestRunner.java:626)
[TestNG] at org.testng.TestRunner.run(TestRunner.java:594)
[TestNG] at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
[TestNG] at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
[TestNG] at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
[TestNG] at org.testng.SuiteRunner.run(SuiteRunner.java:289)
[TestNG] at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
[TestNG] at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
[TestNG] at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
[TestNG] at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
[TestNG] at org.testng.TestNG.runSuites(TestNG.java:1144)
[TestNG] at org.testng.TestNG.run(TestNG.java:1115)
[TestNG] at org.testng.TestNG.privateMain(TestNG.java:1442)
[TestNG] at org.testng.TestNG.main(TestNG.java:1411)
[TestNG] Caused by: java.lang.ClassNotFoundException: io.restassured.RestAssured
[TestNG] at java.net.URLClassLoader.findClass(Unknown Source)
[TestNG] at java.lang.ClassLoader.loadClass(Unknown Source)
[TestNG] at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
[TestNG] at java.lang.ClassLoader.loadClass(Unknown Source)
facing the sam eerror .
ReplyDeleteplease help
java.lang.NoClassDefFoundError: io/restassured/RestAssured
Sorry for replying late Ankit.
DeleteJust Download and downgrade Rest-Assured Jar to version 3.1.0. Rebuild the project. It should get fixed.
DeleteJust Change Scope : Test --> Compile for rest-assured artifact in POM.xml
Thanks . It works, but it has a warning message -
ReplyDeleteWARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass
Any idea how we can remove this warning
Hi Warning should not cause any Issue in project build or execution.
DeleteGot this error of class not found. Changed the scope from test to compile and it worked. thank you so much.
ReplyDeleteIf I get any more errors I'll post it here. Please solve them for me!
Sure! Most Welcome :)
DeleteHi Ishan im using a non-maven project and as you said i downgraded the rest-assured jar to 3.1.0 and rebuild the project and still see the same issue, please help
ReplyDeleteHi Charan!
Delete>>> Go to your .m2 directory and delete the rest-assured folder. (C:\Users\username.m2\repository\io)
Nor try re-building the project.
Hi Ishan,
ReplyDeleteI am seeing this error while configure the eclipse with rest assured. I went back to Jar 3.1.0 but later I am seeing:
Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for C:\Users\b\Desktop\RestAssured\rest-assured3.1.0\rest-assured-3.1.0-dist\rest-assured-3.1.0-deps\groovy-2.4.12.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class groovy not in module
My project does not have pom.xml.
Details:
1. Eclipse IDE for Java Developers (includes Incubating components)
Version: 2020-06 (4.16.0)
2. Jdk 14.0.2
I am new to Java or using eclipse so somewhere I am doing mistake. Any suggestion will be a great help.
Thanks In advance.