title: Permission (java.lang.RuntimePermission exitVM) was not granted while executing jetty stop with Maven Ant Task
body: <p>I get the following ant error in console while running jetty:stop command using mvn tasks,</p>
  
  <pre><code>[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)
  </code></pre>
  
  <p>In search for this error, I got similar posts,</p>
  
  <p><a href="https://stackoverflow.com/a/8588201/1793718">https://stackoverflow.com/a/8588201/1793718</a></p>
  
  <p><a href="https://issues.apache.org/jira/browse/MANTTASKS-201" rel="nofollow noreferrer">https://issues.apache.org/jira/browse/MANTTASKS-201</a></p>
  
  <p><a href="https://readthefuckingmanual.net/error/1010/" rel="nofollow noreferrer">https://readthefuckingmanual.net/error/1010/</a></p>
  
  <p>suggesting setting <code>fork="true"</code> would solve the problem but I get this error when already my fork is set to true(or even false)</p>
  
  <p>Below is my ant target to invoke stop jetty server,</p>
  
  <pre><code>&lt;target name="jetty-stop" fork="true"&gt;
      &lt;artifact:mvn mavenHome="${maven.home}"&gt;
          &lt;jvmarg value="-Xmx1024m" /&gt;
          &lt;arg value="jetty:stop"/&gt;
      &lt;/artifact:mvn&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>Update :</p>
  
  <p>I also noticed error messages while initializing the c3p0 same as mentioned in this question, </p>
  
  <p><a href="https://stackoverflow.com/q/12195868/1793718">java.security.AccessControlException when using Ant, but runs ok when invoking java from console</a></p>
  
  <p>while starting up the server using the following ant-task,</p>
  
  <pre><code>&lt;target name="jetty-start-jdk8"&gt;
      &lt;delete dir="war/WEB-INF/lib"/&gt;
      &lt;artifact:mvn mavenHome="${maven.home}" fork="true"&gt;
          &lt;jvmarg value="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000" /&gt;
          &lt;jvmarg value="-javaagent:${jrebel.path}" /&gt;
          &lt;jvmarg value="-Xbootclasspath/p:C:/Users/admin/AppData/Local/Temp//rebelboot.jar" /&gt;
          &lt;arg value="compile"/&gt;
          &lt;arg value="war:exploded"/&gt;
          &lt;arg value="jetty:run"/&gt;
      &lt;/artifact:mvn&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>The above post also suggests to set <code>fork="true"</code> to solve it. But it's already set to true. What could be the issue here?</p>