Shavi Pathirana :
I am getting the above error in my program while testing testNG. I also installed TestNG plugin through Help -> Install New
.
I am aware that NoClassDefFoundError means that the class is present in the classpath at Compile time, but it doesn't exist in the classpath at Runtime.
Below is my stacktrace.
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/inject/Stage
at org.testng.internal.Configuration.<init>(Configuration.java:33)
at org.testng.TestNG.init(TestNG.java:216)
at org.testng.TestNG.<init>(TestNG.java:200)
at org.testng.remote.AbstractRemoteTestNG.<init>(AbstractRemoteTestNG.java:17)
at org.testng.remote.support.RemoteTestNG6_12.<init>(RemoteTestNG6_12.java:18)
at org.testng.remote.support.RemoteTestNGFactory6_12.createRemoteTestNG(RemoteTestNGFactory6_12.java:16)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:67)
Caused by: java.lang.ClassNotFoundException: com.google.inject.Stage
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 7 more
Im not sure on how to change my classpath file to solve the issue.
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.testng.TESTNG_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
My java class file is also in the src folder which looks like this.
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
public class ScreencastTestClass {
@BeforeTest
public void StartRCServiver() {
System.out.println(" RC server starting......");
}
public void testLogIn() {
System.out.println(" Test is executing......");
}
@AfterTest
public void ShutDownRCServer() {
System.out.println(" RC server stopping......");
}
}
There is no pom file and the below are the existing files and folder structure.
Anish B. :
Add the missing google-guice-core
dependency in the pom.xml
.
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.1.0</version>
</dependency>
or download the jar here and add it to the classpath.
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=409814&siteId=1