'Debugging issue in testng test cases

I am using intelliJ v2021.3.2 (Community Edition)

My project is a java Maven TestNG (v7.4.0) project

When I run test cases it executes successfully, but when I try to debug I get the following error :

Intellij displays error "Test Framework quit unexpectedly"

and this is the error in console

Exception in thread "main" java.lang.ClassCircularityError: java/lang/WeakPairMap$Pair$Weak
    ..
    at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:107)

The following is a code example (I'm using SHAFT engine) but any test case anyway debugging is not working with all

    @Test (priority = 1)
    public void UserCanLogin() {

            homeObject = new HomePage(driver);
            profilePageObject = new ProfilePage(driver);
            loginObject = new LoginPage(driver);

            homeObject.openLoginPage();
            loginObject.UserLogin(individualUserMail, individualUserPassword);

            Validations.assertThat().element(driver, profilePageObject.getProfileIconDropDown()).exists().perform();
            profilePageObject.ProfileIconDropDown();
            profilePageObject.userLogOut();

    }


Solution 1:[1]

Disabling "Instrumenting agent" worked for me. To do that you need to disable the async stack traces agent in "Settings | Build, Execution, Deployment | Debugger | Async Stack Traces"

Solution 2:[2]

A ClassCircularityError is thrown when some class is a (indirect) superclass of itself, some interface (indirectly) extends itself or similar.

So, check if you declared homeObject to be HomePage or other wrong class by mistake. Take a 2nd look at your code and figure out where there is circularity.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rocal
Solution 2 Tal Angel