1
votes

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.

Maven options (I've set this environment variable on my ~/.profile ~/.bashrc etc.)

$ echo $MAVEN_OPTS
-Xmx1024m -Xms256m -XX:MaxPermSize=256m -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000

On Eclipse I've set a Debug profile on a Remote Java Application based on the project I want to debug, with host 127.0.0.1 (not localhost because the Maven profile dev I am using, see below, is explicitly setting that IP address) and port 8000.

Then when I run the application from the command line with the following command (maven is picking a dev profile from the pom file):

$ mvn tomcat:run -P dev

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:

Failed to connect to remote VM. Connection refused.
Connection refused

I suspect the settings from the $MAVEN_OPTS are not pick up from some reason, have a look at the following output from the ps command:

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

More details:

  • java version "1.7.0_25"
  • OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.13.04.2)
  • OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
  • Eclipse Kepler

Please shed some light, thanks and again... Apologies for the dummy question.

2

2 Answers

4
votes

The docs for tomcat:run describe the systemProperties value that you can put in the pom.xml file.

The settings that you have above would look like this in your pom.xml:

<project>
  ...
  <build>
    ...
    <plugins>
      ...
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>tomcat-maven-plugin</artifactId>
        <version>1.2-SNAPSHOT</version>
        <configuration>
          <systemProperties>
            <JAVA_OPTS>-Xmx1024m -Xms256m -XX:MaxPermSize=256m -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000</JAVA_OPTS>
          </systemProperties>
        </configuration>

Also, see this answer.

1
votes

It looks like you are missing a parameter, try adding -Xdebug to your MAVEN_OPTS

Also see: http://wiki.apache.org/tomcat/FAQ/Developing#Q1