java.lang.NoClassDefFoundError error message when integrating with Selenium/Maven/TestNG project
Hi Team, I have a selenium project developed in Selenium Java, Maven and TestNG framework. The framework is like all the dependencies are in one maven project and all the framework related classes are in another project which is dependent on dependencies project.
And my application automation project which is developed in selenium java, maven and testng which is dependent on framework maven project and dependencies project.
When I am integrating this with Test Complete, I am able to copy all src folder, testng xml files, pom.xml into test complete project directory and able to compile it and all the classes are in target\classes directory with no errors. and also added all the dependencies into target\dependency folder
And i have created UnitTesting item and added TestNG and provided the values as mentioned below. But when I am running the class in test complete, it is compiling successfully but giving me the error as NoClassDefFoundError.
I have added the target\classes and dependencies explicitly in Java Bridge also but it is throwing me the same error.
Error:
FAILED: testscripts.smoke.SmokeTest1.createNewCompanyContactAndOrg
java.lang.NoClassDefFoundError: framework/utils/ApplicationLauncher
at testscripts.smoke.SmokeTest1.createNewCompanyContactAndOrg(SmokeTest1.java:15)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139)
at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:664)
at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:228)
at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:63)
at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:961)
at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:201)
at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:148)
at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.testng.TestRunner.privateRun(TestRunner.java:819)
at org.testng.TestRunner.run(TestRunner.java:619)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:443)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:437)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:397)
at org.testng.SuiteRunner.run(SuiteRunner.java:336)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1228)
at org.testng.TestNG.runSuites(TestNG.java:1134)
at org.testng.TestNG.run(TestNG.java:1101)
at org.testng.TestNG.privateMain(TestNG.java:1461)
at org.testng.TestNG.main(TestNG.java:1425)
Caused by: java.lang.ClassNotFoundException: framework.utils.ApplicationLauncher
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
... 28 more
===============================================
Command line test
Tests run: 1, Failures: 1, Skips: 0
===============================================
[INFO ] 2024-12-09 14:40:19,918 framework.utils.DriverHelper:128 - Stopping Win app driver
[INFO ] 2024-12-09 14:40:19,938 framework.core.FrameworkScript:162 - Quitting driver
===============================================
Command line suite
Total tests run: 1, Passes: 0, Failures: 1, Skips: 0
===============================================
As per the error it is not able to find the ApplicationLauncher class during run time. But the class file is present in target\classes folder. I have tried recompiling again and again but the result is same.
PS: I am able to run the selenium project outside the test complete without any issues.