title: MojoExecutionException when trying to profile netbeans project
body: <p>There's about a million bug reports regarding the issue on NetBeans bug tracker but none of them brought me a resolution.</p>
  
  <p>The issue is that when I try to profile my program, like this:</p>
  
  <p><img src="https://i.stack.imgur.com/cgIk7.png" alt="image description"></p>
  
  <p>I get this:</p>
  
  <pre><code>cd C:\MYSELF\programing\java\AutoCall\AutoClient; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.8.0_31" cmd /c "\"\"C:\\Users\\Jakub\\AppData\\Roaming\\NetBeans\\7.4\\maven\\bin\\mvn.bat\" -Dexec.args=\"-agentpath:C:/Users/Jakub/AppData/Roaming/NetBeans/7.4/lib/deployed/jdk16/windows-amd64/profilerinterface.dll=C:\\Users\\Jakub\\AppData\\Roaming\\NetBeans\\7.4\\lib,5140,10 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=C:\\MYSELF\\programing\\java\\AutoCall\\AutoClient\\nbproject\\private\\profiler  -classpath %classpath cz.autoclient.Main\" -Dexec.executable=\"C:\\Program Files\\Java\\jdk1.8.0_31\\bin\\java.exe\" -DnetbeansProjectMappings= -Dmaven.ext.class.path=C:\\Users\\Jakub\\AppData\\Roaming\\NetBeans\\7.4\\maven-nblib\\netbeans-eventspy.jar org.codehaus.mojo:exec-maven-plugin:1.2.1:exec\""
  Running NetBeans Compile On Save execution. Phase execution is skipped and output directories of dependency projects (with Compile on Save turned on) will be used instead of their jar artifacts.
  Scanning for projects...
  
  ------------------------------------------------------------------------
  Building Auto Client 3.0
  ------------------------------------------------------------------------
  
  --- exec-maven-plugin:1.2.1:exec (default-cli) @ autoclient ---
  Profiler Agent: Waiting for connection on port 5140, timeout 10 seconds (Protocol version: 14)
  Profiler Agent Error: Timed out trying to establish connection with client
  Profiler Agent: Initializing...
  Profiler Agent: Options: &gt;C:\Users\Jakub\AppData\Roaming\NetBeans\7.4\lib,5140,10&lt;
  Profiler Agent: Initialized successfully
  ------------------------------------------------------------------------
  BUILD FAILURE
  ------------------------------------------------------------------------
  Total time: 12.012s
  Finished at: Sun Jan 03 20:57:36 CET 2016
  Final Memory: 5M/75M
  ------------------------------------------------------------------------
  Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project autoclient: Command execution failed. Process exited with an error: -1 (Exit value: -1) -&gt; [Help 1]
  
  To see the full stack trace of the errors, re-run Maven with the -e switch.
  Re-run Maven using the -X switch to enable full debug logging.
  
  For more information about the errors and possible solutions, please read the following articles:
  [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
  </code></pre>
  
  <p>This error seems to happen at random - I had several successful profiling sessions, then it happened again.</p>