Issue when scanning import statements

Hi,

Sonarqube v7.7

I am trying to scan import statements to identify the usage of some specific libraries with the help of javafilescanner and public void scanFile method. It is working in local but when i deployed it into sonarqube server and run the scanner, I am getting following error.

Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar failed: A required class was missing while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar: org/sonar/java/checks/helpers/ExpressionsHelper
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/****/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/3.4.0.905/sonar-maven-plugin-3.4.0.905.jar
[ERROR] urls[1] = file:/C:/Users/****/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
[ERROR] urls[2] = file:/C:/Users/****/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[3] = file:/C:/Users/****/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.22/plexus-utils-3.0.22.jar
[ERROR] urls[4] = file:/C:/Users/****/.m2/repository/org/sonarsource/scanner/api/sonar-scanner-api/2.10.0.1189/sonar-scanner-api-2.10.0.1189.jar
[ERROR] urls[5] = file:/C:/Users/****/.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]]

I have deleted .m2 folder and tried running, but getting same error. Can you please help me in resolving the issue.

The ExpressionHelper class is not part of the api package and it is thus not available at runtime.
You would have to avoid using classes outside of the api package when writing your rule, that will work in unit tests but the class is not shared at runtime in classloader. To make this work you can copy the method in expressionhelper.

Thanks Nicolas… I will work on that.