Search code examples
springtomcat7spring-roospring-tool-suitemaven-tomcat-plugin

Spring roo Cannot invoke Tomcat manager: Connection refused: connect


I have a problem deploying my Spring Roo application with Maven, using Spring Tools Suite 3.5.1 . I've been reading posts like this tomcat-maven-plugin 403 error but I continue with the following error:

Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:redeploy (default-cli) on project prueba: Cannot invoke Tomcat manager: Connection refused: connect -> [Help 1]

I'm running the maven doing this:

Right click over the project => Run as => Run configurations => New Maven Build => Goals: tomcat7:deploy

I've set my config files like this:

pom.xml

        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <url>http://127.0.0.1:8080/manager/text</url>
                <server>tomcat</server>
                <path>/prueba</path>
            </configuration>
        </plugin>

tomcat-users.xml

<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users>
    <role rolename="manager-gui"/>
    <role rolename="manager-script"/>
    <user username="tomcat" password="s3cret" roles="manager-script,manager-gui"/>
</tomcat-users>

settings.xml

<settings>
  <servers>
    <server>
      <id>myserver</id>
      <username>tomcat</username>
      <password>s3cret</password>
    </server>
  </servers>
</settings>

Some posts are in controversy because of this line

<url>http://127.0.0.1:8080/manager/text</url>

They say I have to put html instead of text but It doesn't works and I can't rid of this error.

Thanks in advance


Solution

  • Finally I was able to solve this error. I followed the last steps from this blog and my working files have the following content:

    pom.xml

                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.0</version>
                    <configuration>
                        <path>/ssigdl</path>
                        <update>true</update>
                        <url>http://localhost:8080/manager/text</url>
                        <username>tomcat</username>
                        <password>tomcat</password>
                    </configuration>
                </plugin>
    

    Note the password and username are exposed here so I removed the settings.xml file. When you don't want to expose these data you can create the ${user.home}/.m2/settings.xml,

    tomcat-users.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <tomcat-users>
        <role rolename="tomcat"></role>
        <role rolename="manager-gui"></role>
        <role rolename="manager-script"></role>
        <role rolename="admin-gui"></role>
        <user password="tomcat" roles="tomcat,manager-gui,admin-gui,manager-script"
            username="tomcat"></user>
    </tomcat-users>
    

    I just ran the maven command tomcat7:deploy

    IMPORTANT: Don't forget to start the VMware vFabric tc Server Developer Edition (Tomcat) before running the maven command. I believed the tomcat7:deploy command started the server and then try to deploy but you have to start manually the server to deploy succesfully.