使用mvn cobertura插件时权限被拒绝

时间:2013-01-22 01:37:56

标签: maven permissions cobertura

我正在使用maven为UT代码覆盖集合构建我的项目和cobertura。 我的问题是当我尝试构建项目时,我遇到了下面的错误,最后我发现当我发出命令时,cobertura插件导致失败:mvn cobertura:instrument

[INFO] Unable to obtain CommandsFile location.
Embedded error: Permission denied

我试图浏览目录,我认为我有权限。 有没有人见过以前的失败?如何调试?

$ mvn cobertura:instrument
[INFO] Scanning for projects...
[INFO] Reactor build order: 
[INFO]   MyProject
[INFO] ------------------------------------------------------------------------
[INFO] Building XXXXXX
[INFO]    task-segment: [cobertura:instrument]
[INFO] ------------------------------------------------------------------------
[INFO] [cobertura:instrument]
[INFO] Skipping cobertura mojo for project with packaging type 'pom'
[INFO] ------------------------------------------------------------------------
[INFO] Building ato-client
[INFO]    task-segment: [cobertura:instrument]
[INFO] ------------------------------------------------------------------------
[INFO] [cobertura:instrument]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Unable to obtain CommandsFile location.

Embedded error: Permission denied
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Unable to obtain CommandsFile location.
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:703)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:553)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:523)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:332)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:356)
    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.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to obtain CommandsFile location.
    at org.codehaus.mojo.cobertura.tasks.AbstractTask.executeJava(AbstractTask.java:195)
    at org.codehaus.mojo.cobertura.tasks.InstrumentTask.execute(InstrumentTask.java:131)
    at org.codehaus.mojo.cobertura.CoberturaInstrumentMojo.execute(CoberturaInstrumentMojo.java:145)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:678)
    ... 16 more
Caused by: java.io.IOException: Permission denied
    at java.io.UnixFileSystem.createFileExclusively(Native Method)
    at java.io.File.checkAndCreate(File.java:1704)
    at java.io.File.createTempFile(File.java:1792)
    at java.io.File.createTempFile(File.java:1828)
    at net.sourceforge.cobertura.util.CommandLineBuilder.<init>(CommandLineBuilder.java:96)
    at org.codehaus.mojo.cobertura.tasks.CommandLineArguments.getCommandsFile(CommandLineArguments.java:82)
    at org.codehaus.mojo.cobertura.tasks.AbstractTask.executeJava(AbstractTask.java:191)
    ... 20 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Tue Jan 22 09:30:25 CST 2013
[INFO] Final Memory: 22M/241M
[INFO] ------------------------------------------------------------------------

3 个答案:

答案 0 :(得分:3)

我认为您当前的用户没有对临时文件夹的写入权限(请检查java.io.tmpdir系统属性值):

Caused by: java.io.IOException: Permission denied 
at java.io.UnixFileSystem.createFileExclusively(Native Method) 
at java.io.File.checkAndCreate(File.java:1704) 
at java.io.File.createTempFile(File.java:1792) 
at java.io.File.createTempFile(File.java:1828) 
at net.sourceforge.cobertura.util.CommandLineBuilder.(CommandLineBuilder.java:96) 
at enter code here

答案 1 :(得分:2)

错误表示java进程的用户对临时目录(/ tmp)没有写权限。

Java进程会将pid写入临时目录中的文件。

Jps / jstat可以使用此pid文件获取jvm信息。

另见:

答案 2 :(得分:0)

您是否检查过用户是否有权写入java配置提供的标准临时文件目录?