欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Cannot run program "cmd.exe" 和CreateProcess error=740

程序员文章站 2022-05-28 11:10:17
...

今天解决了一个大bug,很开心,哈哈哈,bug如下:

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.665 s
[INFO] Finished at: 2018-01-25T14:32:43+08:00
[INFO] Final Memory: 17M/189M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project pfcase: Error while executing forked tests.; nested exception is java.io.IOException: Cannot run program "cmd.exe" (in directory "G:\Users\Administrator\workspace\bugCatcher"): CreateProcess error=740, 请求的操作需要提升。 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project pfcase: Error while executing forked tests.; nested exception is java.io.IOException: Cannot run program "cmd.exe" (in directory "G:\Users\Administrator\workspace\bugCatcher"): CreateProcess error=740, 请求的操作需要提升。
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
	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:116)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
	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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error while executing forked tests.; nested exception is java.io.IOException: Cannot run program "cmd.exe" (in directory "G:\Users\Administrator\workspace\bugCatcher"): CreateProcess error=740, 请求的操作需要提升。
	at org.apache.maven.plugin.surefire.SurefirePlugin.assertNoException(SurefirePlugin.java:656)
	at org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary(SurefirePlugin.java:645)
	at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:137)
	at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:98)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
	... 19 more
Caused by: org.apache.maven.surefire.booter.SurefireBooterForkException: Error while executing forked tests.; nested exception is java.io.IOException: Cannot run program "cmd.exe" (in directory "G:\Users\Administrator\workspace\bugCatcher"): CreateProcess error=740, 请求的操作需要提升。
	at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:294)
	at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:113)
	at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:199)
	at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAllProviders(AbstractSurefireMojo.java:176)
	at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:135)
	... 22 more
Caused by: java.io.IOException: Cannot run program "cmd.exe" (in directory "G:\Users\Administrator\workspace\bugCatcher"): CreateProcess error=740, 请求的操作需要提升。
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
	at java.lang.Runtime.exec(Runtime.java:620)
	at org.codehaus.plexus.util.cli.Commandline.execute(Commandline.java:651)
	at org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLineAsCallable(CommandLineUtils.java:140)
	at org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLine(CommandLineUtils.java:111)
	at org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLine(CommandLineUtils.java:86)
	at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:276)
	... 26 more
Caused by: java.io.IOException: CreateProcess error=740, 请求的操作需要提升。
	at java.lang.ProcessImpl.create(Native Method)
	at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
	at java.lang.ProcessImpl.start(ProcessImpl.java:137)
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
	... 32 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
当我遇到这个问题的时候,先是在网上查询bug的相关问题,但是都没有解决我的问题,不知道是他们没发现还是我细心!到最后我都查到*上了,那个外国人的解答感觉接近我的答案,但是还不是直接解决办法。

最后我点击我的pom.xml文件中的那个关于maven-surefire-plugin的地方,它显示如下:

Cannot run program "cmd.exe" 和CreateProcess error=740

看到上面显示的是2.12,然后根据提示jump to location ,到如下图处:

Cannot run program "cmd.exe" 和CreateProcess error=740

它bug中显示的有关这个版本号的地方:

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project pfcase: Error while executing forked tests.; nested exception is java.io.IOException: Cannot run program "cmd.exe" (in directory "G:\Users\Administrator\workspace\bugCatcher"): CreateProcess error=740, 请求的操作需要提升。 -> [Help 1]

后面我就去repository中去看这个插件的位置,如图:

Cannot run program "cmd.exe" 和CreateProcess error=740

发现有两个版本号,一个2.12,另一个2.12.4,当时的想法就是会不会我用的2.12在2.12.4高版本的情况下不兼容(也或者这个2.12.4是maven版本自带的插件版本号),后来果断用2.12.4,如图:

Cannot run program "cmd.exe" 和CreateProcess error=740

再次构建maven项目,ok,问题解决!

总结:这个问题就是版本的不兼容导致的,所以报maven-surefire-plugin:2.12:test (default-test) on project pfcase,在测试这个插件的时候报错,最终导致 Cannot run program "cmd.exe" 和CreateProcess error=740, 请求的操作需要提升。



相关标签: surefire