Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy Maven project in Tomcat8 from Eclipse IDE

Tags:

maven

tomcat

<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.

like image 570
Ali Khan Avatar asked Feb 07 '23 00:02

Ali Khan


1 Answers

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.

like image 185
Do Nhu Vy Avatar answered Feb 23 '23 04:02

Do Nhu Vy