A required class was missing org/sonar/java/checks/helpers/ClassPatternsUtils

  • SQ version:
  • Zipped sonar
  • we are running a custom rules plugin.

We have a rule that uses ClassPatternsUtils class


and we have the following dependency in our maven project for the custom rules plugin.


I check that git repo:


we are trying to run:

mvn sonar:sonar

Then we get the following output:

[2023-11-01T13:12:01.141Z] [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin: (default-cli) on project mje: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin: failed: A required class was missing while executing org.sonarsource.scanner.maven:sonar-maven-plugin: org/sonar/java/checks/helpers/ClassPatternsUtils

Do we need to update anything on the SQ server?



Two questions:

  1. Should the sonar-java library be bundled with my custom rules plugin?
    If that is the case I could not see it in the jar file:
0  11-03-2023 08:22   META-INF/lib/
4190123  11-03-2023 08:22   META-INF/lib/org.eclipse.jdt.core-3.33.0.jar
 104269  11-03-2023 08:22   META-INF/lib/org.eclipse.core.contenttype-3.8.200.jar
  19936  11-03-2023 08:22   META-INF/lib/jsr305-3.0.2.jar
 196772  11-03-2023 08:22   META-INF/lib/sonar-regex-parsing-
1539745  11-03-2023 08:22   META-INF/lib/org.eclipse.osgi-3.18.300.jar
3160927  11-03-2023 08:22   META-INF/lib/ecj-3.33.0.jar
   2199  11-03-2023 08:22   META-INF/lib/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar
 610199  11-03-2023 08:22   META-INF/lib/java-frontend-
 150535  11-03-2023 08:22   META-INF/lib/org.eclipse.equinox.common-3.17.0.jar
  41125  11-03-2023 08:22   META-INF/lib/slf4j-api-1.7.36.jar
 119174  11-03-2023 08:22   META-INF/lib/org.eclipse.core.commands-3.10.300.jar
  20165  11-03-2023 08:22   META-INF/lib/org.osgi.service.prefs-1.1.2.jar
10255470  11-03-2023 08:22   META-INF/lib/jdt-
 587402  11-03-2023 08:22   META-INF/lib/commons-lang3-3.12.0.jar
 138992  11-03-2023 08:22   META-INF/lib/org.eclipse.equinox.preferences-3.10.100.jar
 304321  11-03-2023 08:22   META-INF/lib/org.eclipse.text-3.12.300.jar
   8781  11-03-2023 08:22   META-INF/lib/j2objc-annotations-1.3.jar
  76224  11-03-2023 08:22   META-INF/lib/org.eclipse.core.runtime-3.26.100.jar
 258075  11-03-2023 08:22   META-INF/lib/gson-2.8.9.jar
 323669  11-03-2023 08:22   META-INF/lib/picocontainer-2.14.1.jar
 116937  11-03-2023 08:22   META-INF/lib/org.eclipse.core.jobs-3.13.200.jar
   4617  11-03-2023 08:22   META-INF/lib/failureaccess-1.0.1.jar
  35519  11-03-2023 08:22   META-INF/lib/sonar-performance-measure-
 167914  11-03-2023 08:22   META-INF/lib/sslr-squid-bridge-2.6.1.jar
 208835  11-03-2023 08:22   META-INF/lib/checker-qual-3.12.0.jar
 197897  11-03-2023 08:22   META-INF/lib/sslr-core-
  24722  11-03-2023 08:22   META-INF/lib/troubleshooter-1.1.10.jar
  36875  11-03-2023 08:22   META-INF/lib/osgi.annotation-8.0.1.jar
  15979  11-03-2023 08:22   META-INF/lib/error_prone_annotations-2.11.0.jar
 914262  11-03-2023 08:22   META-INF/lib/org.eclipse.core.resources-3.18.200.jar
 112840  11-03-2023 08:22   META-INF/lib/sonar-analyzer-commons-
2959479  11-03-2023 08:22   META-INF/lib/guava-31.1-jre.jar
  1. If it is not the case that sonar-java is bundled where should the dependency come from?



Hi mike,

Are you sure those helpers classes are actually public? My off-hand guess at the problem is that they’re not.


@ganncamp this from the sonar-java github.

and I don’t get any compile errors in my custom rules plugin.

What versions of sonar-java and sonar dependencies should I use in our custom rules plugin in the pom.xml

            <!-- mandatory scope -->

Is it correct?


I’m not qualified to judge. I’ve flagged this for more expert eyes.


Hi Mikael, the class you are trying to use in your code is not part of the org.sonar.plugins.java.api package (the public Sonar APIs), and you will not be able to use it at runtime inside SQ. Within your IDE you do not see issues and you can also compile your code because of the maven dependency, but the classes will not be accessible at runtime inside the SQ instance.

@Leonardo_Pilastri so we can only depend on classes in package org.sonar.plugins.java.api even if they are public.

But we are supposed to have this java dependency in our pom.xml since we use the,
import org.sonar.plugins.java.api.IssuableSubscriptionVisitor class.

Since we need to add the dependency to our custom plugin is there a way to only include this package at compile time when we build with maven?



To my knowledge, Maven does not provide the possibility to import only a package from a dependency. I think you could configure this through your IDE though.