title: remote debugging with maven tomcat and eclipse
body: <p>The same "old question", I am pretty new to Maven and I can not figure out why in the end I am getting a message like "Failed to connect to remote VM. Connection refused." from Eclipse.</p>
  
  <p>Maven options (I've set this environment variable on my <code>~/.profile</code> <code>~/.bashrc</code> etc.)</p>
  
  <pre><code>$ echo $MAVEN_OPTS
  -Xmx1024m -Xms256m -XX:MaxPermSize=256m -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
  </code></pre>
  
  <p>On Eclipse I've set a Debug profile on a <code>Remote Java Application</code> based on the project I want to debug, with host <code>127.0.0.1</code> (not <code>localhost</code> because the Maven profile <code>dev</code> I am using, see below, is explicitly setting that IP address) and port <code>8000</code>.</p>
  
  <p>Then when I run the application from the command line with the following command (maven is picking a <code>dev</code> profile from the pom file):</p>
  
  <pre><code>$ mvn tomcat:run -P dev
  </code></pre>
  
  <p>and I start Eclipse in debug mode on the Eclipse Remote Java Application profile I previously set I am getting a message from an Eclipse popup window saying:</p>
  
  <pre><code>Failed to connect to remote VM. Connection refused.
  Connection refused
  </code></pre>
  
  <p>I suspect the settings from the <code>$MAVEN_OPTS</code> are not pick up from some reason, have a look at the following output from the <code>ps</code> command:</p>
  
  <pre><code>USER_NAME@my-laptop $ ps aux | grep tomcat
  USER_NAME   16526 11.3 13.7 3014276 500680 pts/5  Sl+  11:25   0:29 /usr/lib/jvm/java-7-openjdk-amd64/bin/java -classpath /usr/share/maven/boot/plexus-classworlds-2.x.jar -Dclassworlds.conf=/usr/share/maven/bin/m2.conf -Dmaven.home=/usr/share/maven org.codehaus.plexus.classworlds.launcher.Launcher tomcat:run -P dev
  </code></pre>
  
  <p>More details:</p>
  
  <ul>
  <li>java version "1.7.0_25"</li>
  <li>OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.13.04.2)</li>
  <li>OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)</li>
  <li>Eclipse Kepler</li>
  </ul>
  
  <p>Please shed some light, thanks and again... Apologies for the dummy question.</p>