API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar

Hi Team,

Current we are using sonarqube 7.9 enterprise version, we have upgarded Java analyzer plugin to 6.3, few week back I have reported issue on [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project phts-aggregator: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar failed: A required class was missing while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar: javax/servlet/jsp/jstl/core/ConditionalTagSupport

As per sonar support we have excluded the JSP files from scan and we are good for above, now we are getting below error for a different project . can you please help with us if you have any workaround ?

I tried to exclude JSP files from scan but did not help much

build 14-Jul-2020 08:12:00 [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project epdg-app-aggregator: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/faces/webapp/UIComponentTag
build 14-Jul-2020 08:12:00 [ERROR] -----------------------------------------------------
build 14-Jul-2020 08:12:00 [ERROR] realm = plugin>org.codehaus.mojo:sonar-maven-plugin:3.7.0.1746
build 14-Jul-2020 08:12:00 [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
build 14-Jul-2020 08:12:00 [ERROR] urls[0] = file:/d:/MavenRepo/org/sonarsource/scanner/maven/sonar-maven-plugin/3.7.0.1746/sonar-maven-plugin-3.7.0.1746.jar
build 14-Jul-2020 08:12:00 [ERROR] urls[1] = file:/d:/MavenRepo/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
build 14-Jul-2020 08:12:00 [ERROR] urls[2] = file:/d:/MavenRepo/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
build 14-Jul-2020 08:12:00 [ERROR] urls[3] = file:/d:/MavenRepo/org/codehaus/plexus/plexus-utils/3.2.1/plexus-utils-3.2.1.jar
build 14-Jul-2020 08:12:00 [ERROR] urls[4] = file:/d:/MavenRepo/org/sonarsource/scanner/api/sonar-scanner-api/2.14.0.2002/sonar-scanner-api-2.14.0.2002.jar
build 14-Jul-2020 08:12:00 [ERROR] urls[5] = file:/d:/MavenRepo/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
build 14-Jul-2020 08:12:00 [ERROR] Number of foreign imports: 1
build 14-Jul-2020 08:12:00 [ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
build 14-Jul-2020 08:12:00 [ERROR]
build 14-Jul-2020 08:12:00 [ERROR] -----------------------------------------------------
build 14-Jul-2020 08:12:00 [ERROR] → [Help 1]
build 14-Jul-2020 08:12:00 [ERROR]
build 14-Jul-2020 08:12:00 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
build 14-Jul-2020 08:12:00 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
build 14-Jul-2020 08:12:00 [ERROR]
build 14-Jul-2020 08:12:00 [ERROR] For more information about the errors and possible solutions, please read the following articles:
build 14-Jul-2020 08:12:00 [ERROR] [Help 1] PluginContainerException - Apache Maven - Apache Software Foundation

Thanks
Sachidananda

Hello,

First of all, just so you know the recently release Java 6.3.1 is supposed to fix the problem on JSP files, so you may try to include them again.

About your new problem, this seems to be a dependency problem with JSF. Similar problems have been reported outside of any SonarQube context. You may want to try the fixes suggested at https://stackoverflow.com/questions/7807549/java-lang-classformaterror-absent-code-attribute-in-method-that-is-not-native-o for instance

Olivier

Thank you Olivier, In my POM I do not use JSF dededency, Even I have tried to exclude the JSP file from sonar scan still I am seeing this issue. Can you please have a look if required I will share the log and pom file for further analysis .

Thanks
Sachidananda

Hello @sachidananda,

Yes please share POM and logs.

Please find the attached log and pom file plan-528876942-JOB1-16.log (1.3 MB)

pom.txt (151.3 KB)

Hi @OlivierK did you get an chance to look in to the logs and pom ?

waiting for your favorable reply .

Thanks
Sachidananda

Hi Oliver,

Did you get an chance to look at pom file and build log ?

Waiting for your reply.

Thanks & Regards
Sachidananda

@OlivierK Did you get an chance to look at pom file and build log ?

Waiting for your reply.

Thanks & Regards
Sachidananda

@OlivierK Thank you for your kind support, Issue has been fixed and able build the project successfully

Thanks
Sachidananda

Hello @sachidananda,
Just as a reminder, this is a community forum where you get free support in best effort. You should be more patient and chase less often.
I am just back from holidays and had a look at your POM. In this POM there several dependencies to some custom packages that are likely to contain JSF, the best evidence being that you exclude some javax libs afterwards (JSF faces being part of javax), and that is certainly the root cause. This is most probably not a SonarQube problem.
What I suggest you to do is to build your projects (without analyzing with SonarQube) and then search for presence of the embedded javax.faces package in built targets.
That should help you determine how to modify your POM to not include JSF
Olivier

@OlivierK Thank’s for your kind reply and appreciated for same, I was not aware of that you are on a vacation for a week, sorry to spam your mail box,As mentioned above I found the root cause and fixed it .I feel I should not bothered you .:slight_smile: , In past I got reply and solution quickly that’s why my exceptions was more, I completely forget that I am getting the solution on free, Sorry for the inconvenience caused .

Have a great day & Again Thank you for your Kind support .

Best Regards
Sachidananda

Could you please explain how you fixed this? I’m hitting the same problem.

Hello Olivier,

I am encountering the same problem with a project. To check if a dependency on JSF could be the cause, I checked the effective POM for the presence of javax.faces (running mvn help:effective-pom | grep javax.faces), but I couldn’t find any.

What else could be causing the ‘API’ error?

Vincent

I should also mention that, apart from the “API incompatibility” error message, the detail is different in my case, seemingly having to do with the post-Java 9 module system (mentioned in the last, long line):

java.lang.ExceptionInInitializerError: null 
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/home/jenkins/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/3.9.1.2184/sonar-maven-plugin-3.9.1.2184.jar
[ERROR] urls[1] = file:/home/jenkins/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
[ERROR] urls[2] = file:/home/jenkins/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[3] = file:/home/jenkins/.m2/repository/org/codehaus/plexus/plexus-utils/3.2.1/plexus-utils-3.2.1.jar
[ERROR] urls[4] = file:/home/jenkins/.m2/repository/org/sonarsource/scanner/api/sonar-scanner-api/2.16.2.588/sonar-scanner-api-2.16.2.588.jar
[ERROR] urls[5] = file:/home/jenkins/.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] -----------------------------------------------------: java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @4ad1a276

Hi can you plz share what fix you have done.