gpt4 book ai didi

java - 无法运行 Sonar 扫描

转载 作者:太空宇宙 更新时间:2023-11-04 10:18:12 24 4
gpt4 key购买 nike

使用基本的 hello world 类进行测试,无法克服此错误。它分析的唯一类是一个简单的 HelloWorld 类。目前使用我公司的 Sonar 实例,最后的手段将安装本地实例进行测试。

此问题的其他实例在线讨论版本问题,但我认为我是最新的。我不确定所有插件版本来自哪里,但公司中没有其他人有这个问题,所以我认为它一定是本地的。很高兴提供任何额外的细节。

错误

[ERROR] Unable to create symbol table for : /Users/me/dev/tester/src/main/java/com/mc/test/HelloWorld.java
java.lang.IllegalArgumentException: null
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:170) ~[asm-debug-all-5.0.3.jar:5.0.3]
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:153) ~[asm-debug-all-5.0.3.jar:5.0.3]
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:424) ~[asm-debug-all-5.0.3.jar:5.0.3]
at org.sonar.java.resolve.BytecodeCompleter.loadClass(BytecodeCompleter.java:220) ~[java-frontend-4.5.0.8398.jar:na]
at org.sonar.java.resolve.Symbols.<init>(Symbols.java:176) ~[java-frontend-4.5.0.8398.jar:na]
at org.sonar.java.resolve.SemanticModel.createFor(SemanticModel.java:55) ~[java-frontend-4.5.0.8398.jar:na]
at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:105) ~[java-frontend-4.5.0.8398.jar:na]
at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:84) [java-frontend-4.5.0.8398.jar:na]
at org.sonar.java.ast.JavaAstScanner.scan(JavaAstScanner.java:67) [java-frontend-4.5.0.8398.jar:na]
at org.sonar.java.JavaSquid.scanSources(JavaSquid.java:114) [java-frontend-4.5.0.8398.jar:na]
at org.sonar.java.JavaSquid.scan(JavaSquid.java:108) [java-frontend-4.5.0.8398.jar:na]
at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:87) [sonar-java-plugin-4.5.0.8398.jar:na]
at org.sonar.batch.sensor.SensorWrapper.analyse(SensorWrapper.java:57) [sonar-scanner-engine-shaded-5.6.7.jar:na]
at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58) [sonar-scanner-engine-shaded-5.6.7.jar:na]
at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50) [sonar-scanner-engine-shaded-5.6.7.jar:na]
at org.sonar.batch.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:83) [sonar-scanner-engine-shaded-5.6.7.jar:na]
at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192) [sonar-scanner-engine-shaded-5.6.7.jar:na]
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) [sonar-scanner-engine-shaded-5.6.7.jar:na]
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) [sonar-scanner-engine-shaded-5.6.7.jar:na]
at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241) [sonar-scanner-engine-shaded-5.6.7.jar:na]
at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236) [sonar-scanner-engine-shaded-5.6.7.jar:na]
at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226) [sonar-scanner-engine-shaded-5.6.7.jar:na]
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) [sonar-scanner-engine-shaded-5.6.7.jar:na]
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) [sonar-scanner-engine-shaded-5.6.7.jar:na]
at org.sonar.batch.task.ScanTask.execute(ScanTask.java:47) [sonar-scanner-engine-shaded-5.6.7.jar:na]
at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86) [sonar-scanner-engine-shaded-5.6.7.jar:na]
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) [sonar-scanner-engine-shaded-5.6.7.jar:na]
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) [sonar-scanner-engine-shaded-5.6.7.jar:na]
at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:106) [sonar-scanner-engine-shaded-5.6.7.jar:na]
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119) [sonar-scanner-engine-shaded-5.6.7.jar:na]
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62) [sonar-scanner-api-batch9011538681698632830.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.6.jar:na]
at com.sun.proxy.$Proxy24.execute(Unknown Source) [na:na]
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:240) [sonar-scanner-api-2.6.jar:na]
at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151) [sonar-scanner-api-2.6.jar:na]
at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:78) [sonar-maven-plugin-3.0.2.jar:na]
at org.sonarsource.scanner.maven.SonarQubeMojo.execute(SonarQubeMojo.java:112) [sonar-maven-plugin-3.0.2.jar:na]
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137) [maven-core-3.5.4.jar:3.5.4]
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) [maven-core-3.5.4.jar:3.5.4]
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154) [maven-core-3.5.4.jar:3.5.4]
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146) [maven-core-3.5.4.jar:3.5.4]
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117) [maven-core-3.5.4.jar:3.5.4]
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81) [maven-core-3.5.4.jar:3.5.4]
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56) [maven-core-3.5.4.jar:3.5.4]
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) [maven-core-3.5.4.jar:3.5.4]
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305) [maven-core-3.5.4.jar:3.5.4]
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192) [maven-core-3.5.4.jar:3.5.4]
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105) [maven-core-3.5.4.jar:3.5.4]
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:954) [maven-embedder-3.5.4.jar:3.5.4]
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) [maven-embedder-3.5.4.jar:3.5.4]
at org.apache.maven.cli.MavenCli.main(MavenCli.java:192) [maven-embedder-3.5.4.jar:3.5.4]
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]

Pom

<?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>com.mc.test</groupId>
<artifactId>tester</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<sonar.exclusions>**/*.xml</sonar.exclusions>
<sonar.coverage.exclusions>**/models/*</sonar.coverage.exclusions>
<sonar.host.url>https://sonar.company.com</sonar.host.url>
<sonar.scm.disabled>true</sonar.scm.disabled>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.0.2</version>
</plugin>
</plugins>
</build>
</project>

类别

package com.mc.test;

public class HelloWorld {
public static void main(String[] args) {
System.out.println("hello world");
}
}

相关版本

[INFO] Download sonar-cobertura-plugin-1.7.jar
[INFO] Download sonar-github-plugin-1.4.0.699.jar
[INFO] Download sonar-python-plugin-1.7.0.1195.jar
[INFO] Download sonar-pmd-plugin-2.6.jar
[INFO] Download sonar-android-plugin-1.1.jar
[INFO] Download sonar-scm-svn-plugin-1.4.0.522.jar
[INFO] Download sonar-javascript-plugin-2.20.0.4207.jar
[INFO] Download sonar-csharp-plugin-5.7.0.612.jar
[INFO] Download sonar-findbugs-plugin-3.4.4.jar
[INFO] Download sonar-java-plugin-4.5.0.8398.jar
[INFO] Download sonar-ldap-plugin-2.1.0.507.jar
[INFO] Download sonar-web-plugin-2.5.0.476.jar
[INFO] Download sonar-scm-git-plugin-1.2.jar
[INFO] Download sonar-xml-plugin-1.4.1.jar
[INFO] Download sonar-pitest-plugin-0.7.jar
[INFO] Download sonar-typescript-plugin-1.1.0.1079.jar
[INFO] SonarQube version: 5.6.7

最佳答案

我的 JAVA_HOME 设置为使用 Java10,强制 maven 使用 Java8 解决了该问题。

关于java - 无法运行 Sonar 扫描,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51442946/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com