Class not found error; CustomRuleRepository; after installing custom javascript rule jar

I created a custom javascript rules jar based on this:

Unit tests pass.
Installed jar in …/extentions/plugins
sonarQube would not start.
Got the following error:

2019.03.13 09:56:36 ERROR web[][o.s.s.p.Platform] Background initialization failed. Stopping SonarQube
java.lang.IllegalStateException: Fail to load plugin JavaScript My Rules [jscustom]
        at org.sonar.server.plugins.ServerExtensionInstaller.installExtensions(
        at org.sonar.server.platform.platformlevel.PlatformLevel4.start(
        at org.sonar.server.platform.Platform.start(
        at org.sonar.server.platform.Platform.startLevel34Containers(
        at org.sonar.server.platform.Platform.access$500(
        at org.sonar.server.platform.Platform$1.lambda$doRun$0(
        at org.sonar.server.platform.Platform$AutoStarterRunnable.runIfNotAborted(
        at org.sonar.server.platform.Platform$1.doRun(
        at org.sonar.server.platform.Platform$
Caused by: java.lang.NoClassDefFoundError: org/sonar/plugins/javascript/api/CustomRuleRepository
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(
        at Method)
        at org.sonar.classloader.ClassRealm.loadClassFromSelf(
        at org.sonar.classloader.ParentFirstStrategy.loadClass(
        at org.sonar.classloader.ClassRealm.loadClass(
        at org.sonar.classloader.ClassRealm.loadClass(
        at edu.udel.javascript.JavaScriptMyRulesPlugin.define(

        ... 9 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.sonar.plugins.javascript.api.CustomRuleRepository
        at org.sonar.classloader.ParentFirstStrategy.loadClass(
        at org.sonar.classloader.ClassRealm.loadClass(
        at org.sonar.classloader.ClassRealm.loadClass(
        ... 24 common frames omitted
2019.03.13 09:56:36 INFO  web[][o.s.p.StopWatcher] Stopping process

I don’t know exactly what the 2nd and 3rd bullet point in the instructions means:

  • Attach this plugin to SonarJS through the pom.xml
  • add the dependency to SonarJS

Which pom file is “the” pom.xml? My plugin’s? SonarJS’s? SonarQube’s?
Does SonarJS depend on my plugin or does my plugin depend on SonarJS? What specific syntax should be used?

Any help is appreciated. I’ve been googling in circles for a few hours.

Hey John,

I’m pretty sure you don’t need to update the SonarJS plugin itself, nor SonarQube. So the pom.xml to update would be the one from your custom plugin.

In particular, check that the SonarJS version you are using to build your custom-rule plugin is matching the one installed on your SonarQube instance:

From your logs, it seems that there is no CustomRuleRepository class available in your SonarQube instance… and you need it from your JavaScriptCustomRulesDefinition class.

I just tried with latest release of SonarJS ( and the same custom plugin repository, and it seems to work quite well on my SonarQube instance.

Hope this helps,

1 Like

Michael, Thanks for the reply and the info. I’m in the process of getting SonarJS updated to the latest version and I’ll re-try my plugin.