13

当我使用 SonarQube 5.6.5 运行分析时,我在 java 源代码上收到以下异常。

我正在使用 maven 项目运行此分析:mvn sonar:sonar
几乎每个 jar 都失败了,但它通过了 superpom。我没有写任何源代码,我只是包括 sonarqube 插件。这个错误是由于源代码还是声纳插件?

Unable to create symbol table for : /Users/dagrawa/EInkReader/apps/ramp/src/com/amazon/ebook/ramp/utils/RAMPUtils.java
java.lang.IllegalArgumentException: null
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:185) ~[sonar-java-plugin-4.15.0.12310.jar:na]
    at org.objectweb.asm.ClassReader.<init>(ClassReader.java:168) ~[sonar-java-plugin-4.15.0.12310.jar:na]
    at org.sonar.java.resolve.BytecodeCompleter.loadClass(BytecodeCompleter.java:228) ~[sonar-java-plugin-4.15.0.12310.jar:na]
    at org.sonar.java.resolve.Symbols.<init>(Symbols.java:176) ~[sonar-java-plugin-4.15.0.12310.jar:na]
    at org.sonar.java.resolve.SemanticModel.createFor(SemanticModel.java:58) ~[sonar-java-plugin-4.15.0.12310.jar:na]
    at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:101) ~[sonar-java-plugin-4.15.0.12310.jar:na]
    at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:96) [sonar-java-plugin-4.15.0.12310.jar:na]
    at org.sonar.java.ast.JavaAstScanner.scan(JavaAstScanner.java:68) [sonar-java-plugin-4.15.0.12310.jar:na]
    at org.sonar.java.JavaSquid.scanSources(JavaSquid.java:119) [sonar-java-plugin-4.15.0.12310.jar:na]
    at org.sonar.java.JavaSquid.scan(JavaSquid.java:113) [sonar-java-plugin-4.15.0.12310.jar:na]
    at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:84) [sonar-java-plugin-4.15.0.12310.jar:na]
    at org.sonar.batch.sensor.SensorWrapper.analyse(SensorWrapper.java:57) [sonar-scanner-engine-shaded-5.6.5.jar:na]
    at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58) [sonar-scanner-engine-shaded-5.6.5.jar:na]
    at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50) [sonar-scanner-engine-shaded-5.6.5.jar:na]
    at org.sonar.batch.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:83) [sonar-scanner-engine-shaded-5.6.5.jar:na]
    at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192) [sonar-scanner-engine-shaded-5.6.5.jar:na]
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) [sonar-scanner-engine-shaded-5.6.5.jar:na]
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) [sonar-scanner-engine-shaded-5.6.5.jar:na]
    at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241) [sonar-scanner-engine-shaded-5.6.5.jar:na]
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236) [sonar-scanner-engine-shaded-5.6.5.jar:na]
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:234) [sonar-scanner-engine-shaded-5.6.5.jar:na]
    at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226) [sonar-scanner-engine-shaded-5.6.5.jar:na]
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) [sonar-scanner-engine-shaded-5.6.5.jar:na]
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) [sonar-scanner-engine-shaded-5.6.5.jar:na]
    at org.sonar.batch.task.ScanTask.execute(ScanTask.java:47) [sonar-scanner-engine-shaded-5.6.5.jar:na]
    at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86) [sonar-scanner-engine-shaded-5.6.5.jar:na]
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) [sonar-scanner-engine-shaded-5.6.5.jar:na]
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) [sonar-scanner-engine-shaded-5.6.5.jar:na]
    at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:106) [sonar-scanner-engine-shaded-5.6.5.jar:na]
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119) [sonar-scanner-engine-shaded-5.6.5.jar:na]
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:79) [sonar-scanner-engine-shaded-5.6.5.jar:na]
    at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46) [sonar-scanner-api-batch4958703376323836077.jar:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
    at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60) [sonar-scanner-api-2.10.0.1189.jar:na]
    at com.sun.proxy.$Proxy23.execute(Unknown Source) [na:na]
    at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:171) [sonar-scanner-api-2.10.0.1189.jar:na]
    at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:128) [sonar-scanner-api-2.10.0.1189.jar:na]
    at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:63) [sonar-maven-plugin-3.4.0.905.jar:na]
    at org.sonarsource.scanner.maven.SonarQubeMojo.execute(SonarQubeMojo.java:108) [sonar-maven-plugin-3.4.0.905.jar:na]
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137) [maven-core-3.5.3.jar:3.5.3]
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) [maven-core-3.5.3.jar:3.5.3]
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154) [maven-core-3.5.3.jar:3.5.3]
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146) [maven-core-3.5.3.jar:3.5.3]
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117) [maven-core-3.5.3.jar:3.5.3]
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81) [maven-core-3.5.3.jar:3.5.3]
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56) [maven-core-3.5.3.jar:3.5.3]
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) [maven-core-3.5.3.jar:3.5.3]
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305) [maven-core-3.5.3.jar:3.5.3]
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192) [maven-core-3.5.3.jar:3.5.3]
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105) [maven-core-3.5.3.jar:3.5.3]
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956) [maven-embedder-3.5.3.jar:3.5.3]
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:290) [maven-embedder-3.5.3.jar:3.5.3]
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:194) [maven-embedder-3.5.3.jar:3.5.3]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
        at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) [plexus-classworlds-2.5.2.jar:na]
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) [plexus-classworlds-2.5.2.jar:na]
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) [plexus-classworlds-2.5.2.jar:na]
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) [plexus-classworlds-2.5.2.jar:na]
4

2 回答 2

10

我也遇到过类似的问题。这是因为 @Ahmed Ashour 在上一个答案中所说的 java 版本不兼容。在我们门户的 SonarQube 中,更新管理下的SonarJava插件=> 市场 => 搜索 SonarJava并将其更新到最新版本。然后重新启动 SonarQube。

截图供您参考

于 2018-11-05T06:52:02.033 回答
6

这里的代码中,发生这种情况的原因是您的 Java 版本不符合所需的声纳版本。

当前的声纳要求是 Java 8。

您可以通过以下方式告诉 maven 编译器:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>
于 2018-05-15T10:14:41.043 回答