Note that there are some explanatory texts on larger screens.

plurals
  1. PORun WAR file in /target directory of Maven project by Tomcat
    text
    copied!<p>I'm developing a web application with Java and Maven build system and the web server is Tomcat 7.0.12. After packaging whole project to a WAR file to \target directory by Maven build command, I have to copy it to the webapps folder of Tomcat home to run it. It's very inconvenient, especially when I modified some source files because I have to do all those things (build, copy to Tomcat, run it) again. I've research some articles about Maven, Tomcat, Eclipse on this problem, but there's no result. Could you please help me: 1. How to make Tomcat run the WAR file on target directory of project which is built by Maven command directly? No need to copy/paste the WAR file and restart Tomcat? 2. How can I configure the Tomcat to debug the web application on Eclipse? Thank you so much!</p> <p>BTW, I've read and tried to configure Tomcat, Maven and pom file many times. But I don't know what is the exact configuration, because there are so many advices! Could you provide a particular example of configuration for me? Here is my configuration files:</p> <p>Tomcat tomcat-users.xml</p> <pre><code> &lt;role rolename="manager-gui"/&gt; &lt;user username="admin" password="" roles="manager-gui"/&gt; **&lt;role rolename="manager"/&gt; &lt;user username="admin" password="" roles="manager"/&gt;** &lt;role rolename="admin-gui"/&gt; &lt;user username="admin" password="" roles="admin-gui"/&gt; </code></pre> <p>Maven settings.xml</p> <p> tomcat admin </p> <p>And the pom.xml file of project:</p> <pre><code>&lt;build&gt; &lt;finalName&gt;my-project&lt;/finalName&gt; &lt;defaultGoal&gt;package&lt;/defaultGoal&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt; &lt;artifactId&gt;tomcat-maven-plugin&lt;/artifactId&gt; &lt;version&gt;1.1&lt;/version&gt; &lt;configuration&gt; &lt;server&gt;tomcat&lt;/server&gt; &lt;warFile&gt; ${project.build.directory}/${project.build.finalName}.war&lt;/warFile&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt; // Other plugins &lt;/build&gt; </code></pre> <p>More details: If I run mvn tomcat:deploy before starting a Tomcat instance, the returned error is "Cannot invoke Tomcat manager: Connection refused: connect." Otherwise, if a Tomcat instance has been started before calling mvn tomcat:deploy, the error is "Cannot invoke Tomcat manager: Server returned HTTP response code: 403 for URL: <a href="http://localhost:8080/manager/deploy?path=%2Fmy-project&amp;war=" rel="noreferrer">http://localhost:8080/manager/deploy?path=%2Fmy-project&amp;war=</a>..." </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload