AST扫描期间SonarQube 5.6 FileNotFound异常

时间:2016-07-26 16:22:45

标签: jenkins sonarqube jenkins-plugins sonarqube-scan sonarqube5.6

在AST扫描期间,我得到一个FileNotFoundException寻找symbols-34.pb文件:

ERROR: Error during SonarQube Scanner execution
org.sonar.squidbridge.api.AnalysisException: SonarQube is unable to analyze file : '/workingDir/src/main/java/package/JavaFile.java'
    at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:93)
    at org.sonar.java.ast.JavaAstScanner.scan(JavaAstScanner.java:67)
    at org.sonar.java.JavaSquid.scanSources(JavaSquid.java:133)
    at org.sonar.java.JavaSquid.scan(JavaSquid.java:126)
    at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:93)
    at org.sonar.batch.sensor.SensorWrapper.analyse(SensorWrapper.java:57)
    at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58)
    at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50)
    at org.sonar.batch.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:83)
    at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
    at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241)
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236)
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:234)
    at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
    at org.sonar.batch.task.ScanTask.execute(ScanTask.java:47)
    at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
    at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:106)
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119)
    at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    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:240)
    at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
    at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:110)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:72)
    at org.sonarsource.scanner.cli.Main.main(Main.java:60)
Caused by: org.sonar.core.util.ContextException: Unable to write messages | file=/workingDir/.sonar/batch-report/symbols-34.pb
    at org.sonar.core.util.ContextException.of(ContextException.java:125)
    at org.sonar.core.util.Protobuf.writeStream(Protobuf.java:98)
    at org.sonar.scanner.protocol.output.ScannerReportWriter.writeComponentSymbols(ScannerReportWriter.java:109)
    at org.sonar.batch.sensor.DefaultSensorStorage.store(DefaultSensorStorage.java:202)
    at org.sonar.api.batch.sensor.symbol.internal.DefaultSymbolTable.doSave(DefaultSymbolTable.java:146)
    at org.sonar.api.batch.sensor.internal.DefaultStorable.save(DefaultStorable.java:43)
    at org.sonar.java.ast.visitors.SonarSymbolTableVisitor.visitCompilationUnit(SonarSymbolTableVisitor.java:61)
    at org.sonar.java.model.VisitorsBridge.createSonarSymbolTable(VisitorsBridge.java:176)
    at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:112)
    at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:84)
    ... 35 more
Caused by: java.io.FileNotFoundException: /workingDir/.sonar/batch-report/symbols-34.pb (No such file or directory)
    at java.io.FileOutputStream.open0(Native Method)
    at java.io.FileOutputStream.open(FileOutputStream.java:270)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    at org.sonar.core.util.Protobuf.writeStream(Protobuf.java:95)
    ... 43 more

(匿名改变了路径名称)

java类非常简单,只包含几个注释,可能可以针对Java 6进行编译。我使用的是SonarQube 5.6中Java插件的4.0版。

有人想过为什么会这样吗?

1 个答案:

答案 0 :(得分:0)

我能够解决这个问题。使用SonarQube插件在Jenkins上运行扫描。第二个作业同时在同一个工作区中触发,这导致Jenkins作业(已配置为执行此操作)清除工作区。 symbols.pb文件已删除,然后FileNotFoundException已发生。