java.lang.NoClassDefFoundError: org/sonarsource/analyzer/commons/RuleMetadataLoader


We see this exception

java.lang.NoClassDefFoundError: org/sonarsource/analyzer/commons/RuleMetadataLoader

from a new java custom plug in similar to the community edition. This class is referenced here

    NewRepository repository = context.createRepository(REPOSITORY_KEY, "java").setName(REPOSITORY_NAME);

    RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_BASE_PATH, runtime);

We can see this class defined in sonar-java-plugin and org.sonarsource.analyzer-commons

Sonar 10.0 is used of org.sonarsource.api.plugin is a provided dependency


Using the class directly from the sonar-java plugin is not possible due to the isolated classloaders utilized by the plugins, as explained in the SonarQube docs.

Plugins are loaded in isolated classloaders. It means a plugin can’t access another plugin’s classes. There is an exception for package names following pattern org.sonar.plugins.<pluginKey>.api . For example, all classes in a plugin with the key myplugin that are located in org.sonar.plugins.myplugin.api are visible to other plugins.

In general, a plugin cannot access classes from another plugin, except for those that follow that specific package naming convention. Therefore, only the SonarQube API and classes from* are available to your plugin.

This example seems to be relevant to what you’re implementing: sonar-java/ at master · SonarSource/sonar-java · GitHub

1 Like

thanks @felipebz I used the original sample from

I made the updates from the other link which works better now thanks.

I am having the same issue. Can you share how you fix this issue?