尝试在某些Java源代码上使用sonarQube运行分析并得到此错误:
/opt/sonar/Projects$ sonar-scanner -X
INFO: Scanner configuration file: /opt/sonar/sonar-scanner-2.7/conf/sonar-scanner.properties
INFO: Project root configuration file: /opt/sonar/Projects/sonar-project.properties
INFO: SonarQube Scanner 2.7
INFO: Java 1.8.0_91 Oracle Corporation (64-bit)
INFO: Linux 4.4.0-36-generic amd64
INFO: User cache: /home/alexis/.sonar/cache
DEBUG: Extract sonar-scanner-api-batch in temp...
DEBUG: Get bootstrap index...
DEBUG: Download: http://localhost:9000/sonar/batch_bootstrap/index
DEBUG: Get bootstrap completed
DEBUG: Create isolated classloader...
DEBUG: Start temp cleaning...
DEBUG: Temp cleaning done
DEBUG: Execution getVersion
DEBUG: Execution start
DEBUG: Publish global mode
INFO: Load global repositories
DEBUG: GET 200 http://localhost:9000/sonar/batch/global | time=183ms
INFO: Load global repositories (done) | time=329ms
WARN: Property 'sonar.jdbc.url' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
INFO: User cache: /home/alexis/.sonar/cache
INFO: Load plugins index
DEBUG: GET 200 http://localhost:9000/sonar/deploy/plugins/index.txt | time=15ms
INFO: Load plugins index (done) | time=16ms
DEBUG: Load plugins
INFO: Plugin [l10nfr] defines 'l10nen' as base plugin. This metadata can be removed from manifest of l10n plugins since version 5.2.
DEBUG: Load plugins (done) | time=173ms
DEBUG: API compatibility mode is enabled on plugin C# [csharp] (built with API lower than 5.2)
DEBUG: API compatibility mode is enabled on plugin Git [scmgit] (built with API lower than 5.2)
DEBUG: API compatibility mode is enabled on plugin French Pack [l10nfr] (built with API lower than 5.2)
DEBUG: API compatibility mode is enabled on plugin SVN [scmsvn] (built with API lower than 5.2)
DEBUG: Plugins:
DEBUG: * Java Properties 2.2 (javaProperties)
DEBUG: * C / C++ / Objective-C 4.1 (cpp)
DEBUG: * C# 5.3.2 (csharp)
DEBUG: * Java 4.2 (java)
DEBUG: * Git 1.2 (scmgit)
DEBUG: * French Pack 1.13 (l10nfr)
DEBUG: * SVN 1.3 (scmsvn)
DEBUG: * JavaScript 2.16.0.2922 (javascript)
DEBUG: * PL/SQL 2.8 (plsql)
DEBUG: Execution getVersion
INFO: SonarQube server 6.0
INFO: Default locale: "fr_FR", source code encoding: "UTF-8"
DEBUG: Work directory: /opt/sonar/Projects/.sonar
DEBUG: Execution getVersion
DEBUG: Execution execute
INFO: Process project properties
DEBUG: Process project properties (done) | time=25ms
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 5.295s
INFO: Final Memory: 48M/83M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.ProjectLock
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:69)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:678)
at org.sonar.core.platform.ComponentContainer.getComponentByType(ComponentContainer.java:272)
at org.sonar.scanner.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:108)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:140)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47)
at org.sonar.scanner.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.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:115)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:118)
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:498)
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:244)
at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:154)
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: java.lang.IllegalStateException: Failed to create work directory
at org.sonar.scanner.scan.ProjectLock.<init>(ProjectLock.java:42)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.picocontainer.injectors.AbstractInjector.newInstance(AbstractInjector.java:145)
at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:342)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:67)
... 23 more
Caused by: java.nio.file.AccessDeniedException: /opt/sonar/Projects/.sonar
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:384)
at java.nio.file.Files.createDirectory(Files.java:674)
at java.nio.file.Files.createAndCheckIsDirectory(Files.java:781)
at java.nio.file.Files.createDirectories(Files.java:767)
at org.sonar.scanner.scan.ProjectLock.<init>(ProjectLock.java:39)
... 37 more
已经尝试了各种配置,SonarQube服务器正常工作(localhost:9000没问题),Sonar-Scanner似乎已正确安装。测试从官方sonarqube存储库下载的代码示例,以便conf文件正确。似乎没有任何作用,我不知道是什么导致了这个问题,任何帮助都将受到高度赞赏:)
在虚拟机ubuntu上使用mySQL(最新版本)
答案 0 :(得分:1)
主要问题是aused by: java.nio.file.AccessDeniedException: /opt/sonar/Projects/.sonar
。
您似乎无法访问此目录。您必须检查它并设置正确的访问权限。