Error using AbstractMethodDetection in custom rule


I am currently trying to implement my own java rules.

I followed Custom Rules 101 and I am trying to detect usage of specific methods. I looked in the Java analyzer and found that does what I want by using AbstractMethodDetection.

I had no problems building the plugins but when I’m trying to deploit it, my Sonarqube Instance crash with the following error:

2020.09.22 14:35:51 ERROR web[o.s.s.p.Platform] Background initialization failed. Stopping SonarQube
java.lang.NoClassDefFoundError: org/sonar/java/checks/methods/AbstractMethodDetection

I found this post Unable to deploy custom java rules after using 'AbstractMethodDetection' and from what I understand the AbstractMethodDetection was not available at the time, but should be available from SonarJava version 6.3.
I’m using the latest Sonarqube Docker image which load SonarJava and I still get this error.
I don’t know what I’m missing, so if you would have an idea of what could be wrong, it would be greatly appreciated.
Let me know if you need any information.


PS: Below you’ll find the rule built based on the Custom Rules 101 template.

import org.sonar.check.Priority;
import org.sonar.check.Rule;

		key = "UseFileListRule",
		name = " is used",
		description = " description placeholder",
		priority = Priority.MINOR,
		tags = {"filesystem"})
public class UseFileListCheck extends AbstractMethodDetection {
	  protected MethodMatchers getMethodInvocationMatchers() {
	    return MethodMatchers.create()

	  protected void onMethodInvocationFound(MethodInvocationTree mit) {
	    reportIssue(ExpressionUtils.methodName(mit), "Remove this call to \"list()\".");

Hello @Cybyan,

While you followed the 101, you probably missed the section What you can use, and what you can’t.

In your check, you are using and

These two classes are not exposed in our custom rule API, and won’t be available at runtime. So you simply can not use them.

Hope this helps,

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.