DefaultModuleScannerContext causes errors while verifying against sonar server

I got this issue while scanning a project after created a new custom rule that implements EndOfAnalysis what should be changed to fix this issue ?

Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121:sonar failed: A required class was missing while executing org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121:sonar: org.sonar.java.model.DefaultModuleScannerContext
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.codehaus.mojo:sonar-maven-plugin:4.0.0.4121
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/u/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/4.0.0.4121/sonar-maven-plugin-4.0.0.4121.jar
[ERROR] urls[1] = file:/C:/Users/u/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
[ERROR] urls[2] = file:/C:/Users/u/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.5/plexus-utils-1.5.5.jar
[ERROR] urls[3] = file:/C:/Users/u/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[4] = file:/C:/Users/u/.m2/repository/org/sonarsource/scanner/api/sonar-scanner-api/2.16.3.1081/sonar-scanner-api-2.16.3.1081.jar
[ERROR] urls[5] = file:/C:/Users/u/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR]
[ERROR] → [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sona

Hi.

Are you using the org.sonar.java.model.DefaultModuleScannerContext class in your code?

Only classes in the org.sonar.plugins.java.api package and its subpackages can be accessed by custom plugins, so you can’t use this class.

Hi @Scott thanks for reply I’ trying to make as the overided endOfAnalysis function here what should i do (sonar-java/java-checks/src/main/java/org/sonar/java/checks/design/BrainMethodCheck.java at 570c401b6d36597476e7cff25d7e16fbbf92865d · SonarSource/sonar-java · GitHub)