GradleWorkerMain error while building

I ran into a problem after my work project was updated to Java 11 and to Gradle 7.2. I have tried to delete-reinstall both to no result.

Error: Could not find or load main class Caused by: java.lang.ClassNotFoundException:

This happens when gradle build task gets to tests

The error is not because of IDE, I also get it with running from terminal.

Regenerating wrapper did not help, deleting the user gradle file did not either.

Windows 10 machine, if that changes anything.

Still looking for a solution!