在使用 mvn 任务运行 jetty:stop 命令时,我在控制台中收到以下 ant 错误,
[artifact:mvn] org.apache.tools.ant.ExitException: Permission (java.lang.RuntimePermission exitVM) was not granted.
[artifact:mvn] at org.apache.tools.ant.types.Permissions$MySM.checkExit(Permissions.java:196)
[artifact:mvn] at java.lang.Runtime.exit(Runtime.java:88)
[artifact:mvn] at java.lang.System.exit(System.java:904)
[artifact:mvn] at org.codehaus.classworlds.Launcher.main(Launcher.java:376)
[artifact:mvn] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[artifact:mvn] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[artifact:mvn] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[artifact:mvn] at java.lang.reflect.Method.invoke(Method.java:597)
[artifact:mvn] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217)
[artifact:mvn] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152)
[artifact:mvn] at org.apache.tools.ant.taskdefs.Java.run(Java.java:764)
[artifact:mvn] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:218)
[artifact:mvn] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:132)
[artifact:mvn] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:105)
[artifact:mvn] at org.apache.maven.artifact.ant.Mvn.execute(Mvn.java:81)
[artifact:mvn] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
[artifact:mvn] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[artifact:mvn] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[artifact:mvn] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[artifact:mvn] at java.lang.reflect.Method.invoke(Method.java:597)
[artifact:mvn] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[artifact:mvn] at org.apache.tools.ant.Task.perform(Task.java:348)
[artifact:mvn] at org.apache.tools.ant.Target.execute(Target.java:357)
[artifact:mvn] at org.apache.tools.ant.Target.performTasks(Target.java:385)
[artifact:mvn] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
[artifact:mvn] at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
[artifact:mvn] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[artifact:mvn] at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
[artifact:mvn] at org.apache.tools.ant.Main.runBuild(Main.java:758)
[artifact:mvn] at org.apache.tools.ant.Main.startAnt(Main.java:217)
[artifact:mvn] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
[artifact:mvn] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
为了寻找这个错误,我得到了类似的帖子,
https://stackoverflow.com/a/8588201/1793718
https://issues.apache.org/jira/browse/MANTTASKS-201
https://readthefuckingmanual.net/error/1010/
建议设置fork="true"
可以解决问题,但是当我的 fork 已经设置为 true(甚至是 false)时出现此错误
下面是我调用停止码头服务器的蚂蚁目标,
<target name="jetty-stop" fork="true">
<artifact:mvn mavenHome="${maven.home}">
<jvmarg value="-Xmx1024m" />
<arg value="jetty:stop"/>
</artifact:mvn>
</target>
更新 :
在初始化 c3p0 时,我还注意到错误消息,与此问题中提到的相同,
使用 Ant 时出现 java.security.AccessControlException,但从控制台调用 java 时运行正常
在使用以下 ant 任务启动服务器时,
<target name="jetty-start-jdk8">
<delete dir="war/WEB-INF/lib"/>
<artifact:mvn mavenHome="${maven.home}" fork="true">
<jvmarg value="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000" />
<jvmarg value="-javaagent:${jrebel.path}" />
<jvmarg value="-Xbootclasspath/p:C:/Users/admin/AppData/Local/Temp//rebelboot.jar" />
<arg value="compile"/>
<arg value="war:exploded"/>
<arg value="jetty:run"/>
</artifact:mvn>
</target>
上面的帖子还建议设置fork="true"
解决它。但它已经设置为true。这里可能是什么问题?