Jenkins - Maven 项目 - SonarQube 分析不稳定 - 错误:无法为 - java.lang.IllegalArgumentException 创建符号表:null

Posted

技术标签:

【中文标题】Jenkins - Maven 项目 - SonarQube 分析不稳定 - 错误:无法为 - java.lang.IllegalArgumentException 创建符号表:null【英文标题】:Jenkins - Maven Project - SonarQube Analysis is UNSTABLE - ERROR: Unable to create symbol table for - java.lang.IllegalArgumentException: null 【发布时间】:2020-11-13 10:51:56 【问题描述】:

我在 Sonar 服务器中使用 Java 8 和 apache-maven-3.6.3、sonarqube-7.0、sonar-scanner-cli-4.4.0.2170-windows 和 SonarJava 版本是 5.1(内部版本 13090)

詹金斯 2.235.1

当我构建我的 Jenkins 流水线时,我面临一个问题,即我的构建成功但 SonarQube 分析不稳定

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

这是因为我的项目中的每个测试文件都出现以下错误:

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)

由于上述原因,我的质量门在 Sonar Sever 中显示失败

我已经尽力了,请你帮我解决这个问题吗?

在 Jenkins 中,构建管道 --> 配置,我正在使用以下内容:

    在构建环境中 --> 选择了“准备 SonarQube 扫描仪环境”选项

    在构建中 --> 目标和选项 -->

    全新安装 -U sonar:sonar -Pcoverage -e -Dmaven.test.failure.ignore=true

    在后期步骤中 --> 执行 SonarQuberScanner --> 分析属性

    元数据

    sonar.host.url=http://localhost:9002 sonar.projectName='自动化' sonar.projectKey=数字:数字 sonar.login=管理员 声纳密码=管理员 sonar.projectBaseDir=C:/java-workspace/Digital

    来源信息

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

    测试

    sonar.tests=src/test sonar.surefire.reportsPath=目标/surefire-reports sonar.jacoco.reportPaths=目标/jacoco.exec sonar.java.binaries=目标/类 sonar.java.coveragePlugin=jacoco'

请按如下方式找到我的 POM.xml:

<?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>

**

有人可以帮忙吗?如何解决?

**

【问题讨论】:

【参考方案1】:

我现在升级了:-

jdk-11.0.2 sonarqube-8.4.1.35646, 声纳服务器中的 SonarJava 6.5.1(内部版本 22586) Maven 3.7.0.1746 的声纳扫描仪 詹金斯 2.235.1

现在面临一个新问题:-

[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)

【讨论】:

以上是关于Jenkins - Maven 项目 - SonarQube 分析不稳定 - 错误:无法为 - java.lang.IllegalArgumentException 创建符号表:null的主要内容,如果未能解决你的问题,请参考以下文章

Jenkins——Jenkins构建Maven项目(三种风格)+Jenkins项目构建细节

SonarQube 7.9.1 无法扫描通过 Jenkins 运行的 .net 项目的 .cs 和 sql 文件

Jenkins构建远程maven项目

jenkins为啥只打印maven的构建日志,不显示项目启动日志?

Jenkins构建Maven项目和Pipeline项目

Jenkins构建Maven项目和Pipeline项目