Sonarqube scanner - java compatibility issue

We are using Sonarqube V8.9 and our developers are using Java 1.8 for their code compilation . In IBM Urban Code Build we are using openjdk11 for Sonarqube Scanner. During Sonarqube analysis in Urban Code Build for Java 1.8 applications code compilations we are getting java compatibility issues.

Error:-

> Configure project :
 ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
 Lint disabled for CI Server Run
 
 > Task :compileJava NO-SOURCE
 > Task :compileGroovy NO-SOURCE
 > Task :processResources NO-SOURCE
 > Task :classes UP-TO-DATE
 > Task :compileTestJava NO-SOURCE
 > Task :compileTestGroovy NO-SOURCE
 > Task :processTestResources NO-SOURCE
 > Task :testClasses UP-TO-DATE
 > Task :test NO-SOURCE
 /p01/app/ibm/ucb/agent/var/work/project/com_hmhs_medical_shoppingexperience/sxesvc/sxesvc-common/src/main/java/com/hmhs/sxe/messages/BaseMessage.java:6: error: package javax.xml.bind.annotation does not exist
 import javax.xml.bind.annotation.XmlAccessType;
                                 
 /p01/app/ibm/ucb/agent/var/work/project/com_hmhs_medical_shoppingexperience/sxesvc/sxesvc-common/src/main/java/com/hmhs/sxe/messages/BaseMessage.java:7: error: package javax.xml.bind.annotation does not exist
 import javax.xml.bind.annotation.XmlAccessorType;
                                 
 /p01/app/ibm/ucb/agent/var/work/project/com_hmhs_medical_shoppingexperience/sxesvc/sxesvc-common/src/main/java/com/hmhs/sxe/messages/BaseMessage.java:8: error: package javax.xml.bind.annotation does not exist
 import javax.xml.bind.annotation.XmlType;
                                 
 /p01/app/ibm/ucb/agent/var/work/project/com_hmhs_medical_shoppingexperience/sxesvc/sxesvc-common/src/main/java/com/hmhs/sxe/messages/BaseMessage.java:22: error: cannot find symbol
 XmlAccessorType(XmlAccessType.FIELD)
  
   symbol: class XmlAccessorType
 /p01/app/ibm/ucb/agent/var/work/project/com_hmhs_medical_shoppingexperience/sxesvc/sxesvc-common/src/main/java/com/hmhs/sxe/messages/BaseMessage.java:23: error: cannot find symbol
 XmlType(
  
   symbol: class XmlType
 /p01/app/ibm/ucb/agent/var/work/project/com_hmhs_medical_shoppingexperience/sxesvc/sxesvc-common/src/main/java/com/hmhs/sxe/util/HMUtility.java:20: error: package javax.xml.bind does not exist
 import javax.xml.bind.DatatypeConverter;
                      
 
 Task :sxesvc-common:compileJava
 /p01/app/ibm/ucb/agent/var/work/project/com_hmhs_medical_shoppingexperience/sxesvc/sxesvc-common/src/main/java/com/hmhs/sxe/messages/highview/ImageStoreResponse.java:3: error: package javax.xml.bind.annotation does not exist
 import javax.xml.bind.annotation.XmlAccessType;
                                 
 /p01/app/ibm/ucb/agent/var/work/project/com_hmhs_medical_shoppingexperience/sxesvc/sxesvc-common/src/main/java/com/hmhs/sxe/messages/highview/ImageStoreResponse.java:4: error: package javax.xml.bind.annotation does not exist
 import javax.xml.bind.annotation.XmlAccessorType;
                                 
 /p01/app/ibm/ucb/agent/var/work/project/com_hmhs_medical_shoppingexperience/sxesvc/sxesvc-common/src/main/java/com/hmhs/sxe/messages/highview/ImageStoreResponse.java:5: error: package javax.xml.bind.annotation does not exist
 import javax.xml.bind.annotation.XmlRootElement;
                                 
 /p01/app/ibm/ucb/agent/var/work/project/com_hmhs_medical_shoppingexperience/sxesvc/sxesvc-common/src/main/java/com/hmhs/sxe/messages/highview/ImageStoreResponse.java:6: error: package javax.xml.bind.annotation does not exist
 import javax.xml.bind.annotation.XmlSchemaType

Hey there.

What task is actually failing here?

Hi Colin

The issue is for Springboot JAVA (JDK1.8 version) code, is failing on Sonarqube Gradle Job and below is the script which we are using for Sonar Gradle Job - And we are using Sonarqube V8.9 (build 43852) developers are using Java 1.8 and for their code compilation . In IBM Urban Code Build we are using openjdk11 for Sonarqube Scanner. During Sonarqube analysis in Urban Code Build for Java 1.8 applications code compilations are getting java compatibility issues and Builds are failing.

Sonarqube Gradle Job :-
export JAVA_HOME=/p01/app/java/openjdk11
export PATH=${JAVA_HOME}/bin:${PATH}
chmod 775 ${p:work.dir.path}/gradlew

GRADLE_EXEC=${p:work.dir.path}/gradlew
GRADLE_ARGS=“–console=plain --no-daemon -g ${a:gradle.user.home} sonarqube -Pci_server=true -Pbuildversion=${p:syzygy.version} -PsonarToken=${p:SonarQubeTooladmin}”

echo “Running ${GRADLE_EXEC} ${GRADLE_ARGS}”

${GRADLE_EXEC} ${GRADLE_ARGS}

It looks like you might be running gradle sonarqube outside of where you’ve run your build – which means the build has to run again. You should run gradle sonarqube (after changing the JAVA_HOME variable) immediately after the build, in an environment where the build artifacts still exist.

Previously we were using Sonarqube 7.9v and that time we were running gradle & Sonarqube scanner in same run gradle step as java 1.8 also compatable with sonarqube 7.9v. But after updating Sonarqube 8.9v it’s not supporting jdk1.8 so we created separate steps for running gradle (uses jdk 1.8) and Sonarqube gradle step (uses openjdk11)

Run Gradle:- (Using Java Version : jdk1.8)

export #JAVA_HOME=/p01/app/ibm/was/8.5/deploymgr/${p:gradle.java.version}
JAVA_HOME2=/p01/app/java/${p:gradle.java.version}
export JAVA_HOME=${JAVA_HOME2}
export PATH=${JAVA_HOME2}/bin:${PATH}
chmod 775 ${p:work.dir.path}/gradlew