TypeVariableJavaType cannot be cast to class org.sonar.java.resolve.ClassJavaType

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)

  • what are you trying to achieve
    Im running a Spring boot java application with Circleci as CD.
    My application Builds and Intellij IDE Integrated SonarLint checks are successful. But Sonarcloud test fails with this exception.
    I have a service method which returns two different object based on the method arguments, So i have declared the method’s return type as T. The application runs fine and returns the desired result. But the circleci job test-sonar fails with this exception.

Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin: (default-cli) on project orders: SonarQube is unable to analyze file : ‘xxx/xxxx/Service.java’: class org.sonar.java.resolve.TypeVariableJavaType cannot be cast to class org.sonar.java.resolve.ClassJavaType (org.sonar.java.resolve.TypeVariableJavaType and org.sonar.java.resolve.ClassJavaType are in unnamed module of loader org.sonar.classloader.ClassRealm @724dc44d)

  • what have you tried so far to achieve this
    Need Help on this. I couldnt find any solution to it.


It’s really hard to identify the origin of the problem without any code. In order to help you, can you provide us a minimal piece of code that produce the unexpected behavior?