4
<groupId>org.apache.tomcat.maven</groupId>
   <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <url>http://localhost:8099/manager/html</url>
                <username>tomcat</username>
                <password>admin</password>
                <path>/example</path>
            </configuration>

Cannot invoke Tomcat manager:

 Connection refused: connect -> [Help 1]

Why this error? I am using Apache Tomcat 8.

Vy Do
  • 46,709
  • 59
  • 215
  • 313
Ali Khan
  • 61
  • 1
  • 1
  • 4
  • Your question says you want to deploy the the application on tomcat 8 whereas the you are using maven tomcat 7 plugin in your pom.xml. – RITZ XAVI Oct 05 '16 at 13:38

1 Answers1

8

When you want Maven deploy your web application (WAR artifact) to Tomcat 8 server, you still use tomcat7-maven-plugin.

Inside pom.xml

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

Inside Maven installed directory, looking file settings.xml, path likes this /apache-maven-3.3.9/conf/settings.xml

<servers>
  <server>
    <id>tomcat8_vy</id>
    <username>tomcat_username</username>
    <password>tomcat_password</password>
  </server>
</servers>

Inside Tomcat installed directory, looking file tomcat-users.xml, path likes this /apache-tomcat-8.0.36/conf/tomcat-users.xml

<tomcat-users xmlns="http://tomcat.apache.org/xml"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
              version="1.0">
  <role rolename="manager-gui"/>
  <role rolename="manager-status"/>
  <role rolename="manager-script"/>
  <role rolename="manager-jmx"/>
  <user username="tomcat_username" password="tomcat_password" roles="manger-gui,manager-status,manager-script,manager-jmx"/>
</tomcat-users>

Go to directory of web-app where have pom.xml, type command

mvn tomcat7:deploy

or

mvn tomcat7:redeploy

for second deploy onward (If server no shutdown).

You can run/execute deploy from IDE's Maven plug-in.

Community
  • 1
  • 1
Vy Do
  • 46,709
  • 59
  • 215
  • 313
  • How to deploy with port 8099. – Ali Khan Oct 05 '16 at 16:08
  • Solution 1: `mvn -Dmaven.tomcat.port=8099 tomcat7:deploy`. Solution 2: Set value for `maven.tomcat.port` inside `properties` tag pairs in `pom.xml`. Solution 3: http://stackoverflow.com/a/15805169/3728901 – Vy Do Oct 05 '16 at 16:13
  • If I have tomcat 6 7 and 8. Then how maven will differentiate tomcat version. – Ali Khan Oct 05 '16 at 16:15