I have a javaee project that has the following dependency:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<scope>provided</scope>
</dependency>
The project builds, packages and deploys properly / as expected. However, when I try to run a SonarQube build for this project, I get the following types of warnings with a final fatal error
Nov 04, 2015 11:18:31 AM net.sourceforge.pmd.lang.java.typeresolution.ClassTypeResolver visit
WARNING: Could not find class com.admin.agent.AgentAdminController, due to: java.lang.ClassFormatError: JVMCFRE074 no Code attribute specified; class=javax/servlet/GenericServlet, method=<init>()V, pc=0
....
....
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.7.1:sonar (default-cli) on project build: Execution default-cli of goal org.codehaus.mojo:sonar-maven-plugin:2.7.1:sonar failed: An API incompatibility was encountered while executing org.codehaus.mojo:sonar-maven-plugin:2.7.1:sonar: java.lang.ClassFormatError: JVMCFRE074 no Code attribute specified; class=javax/servlet/jsp/PageContext, method=<init>()V, pc=0
After a bunch of searching, I have found the culprit to be the javaee-api dependency. Being an API only (no implementation) SonarQube complains of missing classes. The only solution I have found is to replace the dependency with a jboss implementation:
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
However, this does not work well for me. I had to modify my pom and remove my original javaee-api dependency and replace it. This means that none of my builds can use the javax.javaee-api dependency?
As far as I am concerned a functional Maven build should be scannable by Sonar.
How can I indicate to Sonar that I want it to use a different dependency for the build (instead of the one in the project pom), or have it ignore the javax.javaee-api dependency altogether?