0

我正在尝试在 Ubuntu 12.04 机器上设置声纳。但是,当我运行mvn(maven 3.0.4)时,它会因为这个异常而失败。声纳服务器运行良好,我可以从浏览器访问它。

这是我在 settings.xml (~/.m2/settings.xml) 中的声纳配置文件

<profiles>
 <profile>
  <id>sonar</id>
  <activation>
     <activeByDefault>true</activeByDefault>
  </activation>
  <properties>
     <sonar.jdbc.url>jdbc:h2:tcp://localhost:9092/sonar</sonar.jdbc.url>
     <sonar.jdbc.driver>org.h2.Driver</sonar.jdbc.driver>
     <sonar.jdbc.username>sonar</sonar.jdbc.username>
     <sonar.jdbc.password>sonar</sonar.jdbc.password>
  </properties>
 </profile>
</profiles>

例外:

[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (default-cli) on project configurator: Can not execute Sonar: IllegalStateException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal     org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (default-cli) on project configurator: Can not     execute Sonar
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Can not execute Sonar
at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:118)
at org.codehaus.mojo.sonar.Bootstraper.start(Bootstraper.java:65)
at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:90)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: java.lang.IllegalStateException
at org.sonar.home.cache.FileCache.newTempFile(FileCache.java:143)
at org.sonar.home.cache.FileCache.get(FileCache.java:83)
at org.sonar.batch.bootstrap.PluginDownloader.downloadPlugin(PluginDownloader.java:53)
at org.sonar.batch.bootstrap.BatchPluginRepository.doStart(BatchPluginRepository.java:74)
at org.sonar.batch.bootstrap.BatchPluginRepository.start(BatchPluginRepository.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110)
at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89)
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84)
at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)
at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)
at org.picocontainer.behaviors.Stored.start(Stored.java:110)
at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1009)
at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1002)
at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:760)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:72)
at org.sonar.batch.bootstrap.Container.start(Container.java:71)
at org.sonar.batch.bootstrapper.Batch.startBatch(Batch.java:88)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:72)
at org.sonar.maven3.SonarMojo.execute(SonarMojo.java:142)
at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:113)
... 23 more

如果您需要任何其他信息,请告诉我。

4

1 回答 1

2

堆栈跟踪告诉我们,自 2011 年 11 月 5 日以来,当前插件已经org.codehaus.mojo:sonar-maven-plugin:2.0相当老了。

我建议不要在我们的 pom.xml 中将其定义为使用 Maven进行分析中的提及:推荐方式如下:-

mvn clean install -DskipTests=true
mvn sonar:sonar

skipTests=true 不运行单元测试两次:安装目标期间和声纳目标期间。您还可以停用集成测试执行。请参阅 Maven 文档。

无论如何,如果您想明确定义它,请使用与您的 Sonar 服务器版本匹配的最新版本。例如,我正在使用当前的 Sonar 服务器版本 3.5。插件应该是,org.codehaus.sonar:sonar-maven-plugin:3.5或者org.codehaus.sonar:sonar-maven3-plugin:3.5

甚至安装和配置 Maven也告诉我们sonar.host.url是可选的(默认是http://localhost:9000),我也想鼓励明确定义它。

我希望这可能会有所帮助。

于 2013-03-22T01:04:07.947 回答