Код отслеживания Google Analytics.

Jul 30, 2011

maven deploy for Tomcat

Maven use Tomcat Maven Plugin for manage tomcat. But some instructions are obsolete and there are a lot of questions in internet.

Following answers don't cover all possible reasons but probably they will hep you.
Server returned HTTP response code: 403
I don't know when it happens but Tomcat change format of manager url. At least in my 7.0 it should be not
Please review documentation for your tomcat manager. In my case it was described at http://localhost:8080/docs/manager-howto.html#Supported_Manager_Commands
My file pom.xml is:

Server returned HTTP response code: 401
The same as above there are some changes in Tomcat 7.0. For grant access to manager user we should not write in $CATALINA_BASE/conf/tomcat-users.xml
<role rolename="manager"/>
<user username="username1" password="password1" roles="manager"/>
how it was before, but
<user name="username1" password="password1" roles="standard,manager-script,manager-gui" />
Please review your tomcat manager documentation (http://localhost:8080/docs/manager-howto.html#Configuring_Manager_Application_Access in my case). Roles are predefined. You need to grant "manager-script" for use manager with maven and "manager-gui" for GUI interface.
We also have to copy user name and password in our maven settings file (~/.m2/settings.xml by default):
please note "server" element should be child of "servers". In some articles it is not clear enough. id is the same as in pom.xml.
This is all. For test we can start list command:
$mvn tomcat:list
[INFO] Listing applications at http://localhost:8080/manager/text
[INFO] OK - Listed applications for virtual host localhost
[INFO] /:running:0:ROOT
[INFO] /manager:running:8:manager
[INFO] /docs:running:0:docs
[INFO] /examples:running:0:examples
[INFO] /host-manager:running:0:host-manager
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
Other goals can be found in "tomcat:help". I left here only most interesting.
$mvn tomcat:help
This plugin has 19 goals:

  Deploy a WAR to Tomcat.


  Redeploy a WAR in Tomcat. Deploy with forcing update flag to true


  Runs the current project as a dynamic web application using an embedded Tomcat


No comments: