1
votes

I am using Java 8 with apache-maven-3.6.3, sonarqube-7.0, sonar-scanner-cli-4.4.0.2170-windows and SonarJava version is 5.1 (build 13090) in Sonar Server

Jenkins 2.235.1

When I build my Jenkins Pipeline, I am facing an issue where my build is success but SonarQube Analysis is UNSTABLE

BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:18 min
[INFO] Finished at: 2020-07-23T21:15:40+05:30
[INFO] ------------------------------------------------------------------------
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeeded?
SonarQube analysis completed: UNSTABLE
Finished: UNSTABLE

This is because I getting following error for every test file in my project:

ERROR: Unable to create symbol table for : QuickPayTest.java
java.lang.IllegalArgumentException: null
         at org.objectweb.asm.ClassReader.<init>(ClassReader.java:160)
         at org.objectweb.asm.ClassReader.<init>(ClassReader.java:143)
         at org.sonar.java.resolve.BytecodeCompleter.loadClass(BytecodeCompleter.java:204)
         at org.sonar.java.resolve.Symbols.<init>(Symbols.java:176)
         at org.sonar.java.resolve.SemanticModel.createFor(SemanticModel.java:59)
         at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:110)
         at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:96)
         at org.sonar.java.ast.JavaAstScanner.scan(JavaAstScanner.java:68)
         at org.sonar.java.JavaSquid.scanTests(JavaSquid.java:126)
         at org.sonar.java.JavaSquid.scan(JavaSquid.java:115)
         at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:91)
         at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)
         at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:88)
         at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:82)
         at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:68)
         at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:88)
         at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:180)
         at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
         at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
         at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:288)
         at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:283)
         at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:261)
         at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
         at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
         at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
         at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:84)
         at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
         at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
         at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:121)
         at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
         at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:71)
         at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.base/java.lang.reflect.Method.invoke(Unknown Source)
         at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
         at com.sun.proxy.$Proxy0.execute(Unknown Source)
         at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
         at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
         at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
         at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
         at org.sonarsource.scanner.cli.Main.main(Main.java:61)

Due to above, my Quality Gate is showing failed in Sonar Sever

I’ve tried everything I could, Can you help me resolve this please ?

In Jenkins, Build Pipeline --> Configure, I am using following:

  1. In Build Environment --> ‘Prepare SonarQube Scanner environment’ option is selected

  2. In Build --> Goals and Options -->

    clean install -U sonar:sonar -Pcoverage -e -Dmaven.test.failure.ignore=true

  3. In Post Steps --> Execute SonarQuberScanner --> Analysis Properties

    Metadata

    sonar.host.url=http://localhost:9002 sonar.projectName='Automation' sonar.projectKey=Digital:Digital sonar.login=admin sonar.password=admin sonar.projectBaseDir=C:/java-workspace/Digital

    Source information

    sonar.sources=src/main sonar.sourceEncoding=UTF-8 sonar.language=java

    Tests

    sonar.tests=src/test sonar.surefire.reportsPath=target/surefire-reports sonar.jacoco.reportPaths=target/jacoco.exec sonar.java.binaries=target/classes sonar.java.coveragePlugin=jacoco'

Please find my POM.xml as follows :

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>Digital</groupId>
    <artifactId>Digital</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>Automation</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven-compiler-plugin-version>2.3.2</maven-compiler-plugin-version>
        <sonar.projectBaseDir>.</sonar.projectBaseDir>
    </properties>
    <build>
        <!-- Source directory configuration -->
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M3</version>
                <configuration>
                    <testFailureIgnore>true</testFailureIgnore>
                    <suiteXmlFiles>
                        <suiteXmlFile>Runnerfile/testng.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>
            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>sonar-maven-plugin</artifactId>
              <version>3.6.1.1688</version>
            </plugin>
            <!-- Compiler plugin configures the java version to be usedfor compiling 
                the code -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin-version}</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.5</version>
                <configuration>
                    <append>true</append>
                  </configuration>
                  <executions>
                    <execution>
                      <goals>
                        <goal>prepare-agent</goal>
                      </goals>
                    </execution>
                    <execution>
                      <id>post-unit-test</id>
                      <phase>test</phase>
                      <goals>
                        <goal>report</goal>
                      </goals>
                    </execution>
                  </executions>
            </plugin>
        </plugins>
    </build>
    <dependencies>

        <dependency>
            <groupId>io.github.bonigarcia</groupId>
            <artifactId>webdrivermanager</artifactId>
            <version>3.0.0</version>
            <scope>compile</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>3.0.0</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-server</artifactId>
            <version>3.141.59</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.11.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.11.1</version>
        </dependency>

        <dependency>
            <groupId>com.sikulix</groupId>
            <artifactId>sikulixapi</artifactId>
            <version>1.1.0</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.jexcelapi</groupId>
            <artifactId>jxl</artifactId>
            <version>2.6.12</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.9</version>
        </dependency>
        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongodb-driver</artifactId>
            <version>3.11.0</version>
        </dependency>
        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>bson</artifactId>
            <version>3.11.0</version>
        </dependency>
        <dependency>
            <groupId>dom4j</groupId>
            <artifactId>dom4j</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.6</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.6</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
            <version>4.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.xmlbeans</groupId>
            <artifactId>xmlbeans</artifactId>
            <version>2.6.0</version>
        </dependency>
        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>2.3.23</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.5</version>
        </dependency>
        <dependency>
            <groupId>stax</groupId>
            <artifactId>stax-api</artifactId>
            <version>1.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.11</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.11</version>
        </dependency>
        <dependency>
            <groupId>com.aventstack</groupId>
            <artifactId>extentreports</artifactId>
            <version>3.1.5</version>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.8.8</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.beust</groupId>
            <artifactId>jcommander</artifactId>
            <version>1.72</version>
        </dependency>
        <dependency>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
            <version>1.24</version>
        </dependency>
        <dependency>
            <groupId>org.beanshell</groupId>
            <artifactId>bsh</artifactId>
            <version>2.0b4</version>
        </dependency>
        <dependency>
            <groupId>com.browserstack</groupId>
            <artifactId>browserstack-local-java</artifactId>
            <version>0.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1.1</version>
        </dependency>
    </dependencies>
</project>

**

Can Someone help here please ? How to resolve this ?

**

1

1 Answers

0
votes

I am now upgraded :-

jdk-11.0.2 sonarqube-8.4.1.35646, SonarJava 6.5.1 (build 22586) in Sonar Server Sonar Scanner for Maven 3.7.0.1746 Jenkins 2.235.1

Now facing a new issue :-

[DEBUG] 01:19:40.520 Could not complete symbolic execution:
org.sonar.java.se.ExplodedGraphWalker$MaximumStepsReachedException: reached limit of 16000 steps for method navigateToClaimslinks_PLS#609 in class Addpolicy
at org.sonar.java.se.ExplodedGraphWalker.throwMaxSteps(ExplodedGraphWalker.java:308)
at org.sonar.java.se.ExplodedGraphWalker.execute(ExplodedGraphWalker.java:247)
at org.sonar.java.se.ExplodedGraphWalker.visitMethod(ExplodedGraphWalker.java:220)
at org.sonar.java.se.ExplodedGraphWalker.visitMethod(ExplodedGraphWalker.java:212)
at org.sonar.java.se.SymbolicExecutionVisitor.execute(SymbolicExecutionVisitor.java:77)
at org.sonar.java.se.SymbolicExecutionVisitor.visitNode(SymbolicExecutionVisitor.java:63)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:103)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visitChildren(SubscriptionVisitor.java:128)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:105)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visitChildren(SubscriptionVisitor.java:128)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:105)
at org.sonar.java.ast.visitors.SubscriptionVisitor.scanTree(SubscriptionVisitor.java:86)
at org.sonar.java.ast.visitors.SubscriptionVisitor.scanFile(SubscriptionVisitor.java:72)
at org.sonar.java.se.SymbolicExecutionVisitor.scanFile(SymbolicExecutionVisitor.java:53)
at org.sonar.java.model.VisitorsBridge.lambda$runScanner$0(VisitorsBridge.java:184)
at org.sonar.java.model.VisitorsBridge.runScanner(VisitorsBridge.java:189)
at org.sonar.java.model.VisitorsBridge.runScanner(VisitorsBridge.java:184)
at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:155)
at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:98)
at org.sonar.java.ast.JavaAstScanner.scan(JavaAstScanner.java:64)
at org.sonar.java.JavaSquid.scanSources(JavaSquid.java:120)
at org.sonar.java.JavaSquid.scan(JavaSquid.java:113)
at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:103)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:388)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:384)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:353)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:144)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy25.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:65)
at org.sonarsource.scanner.maven.SonarQubeMojo.execute(SonarQubeMojo.java:104)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)