Wednesday, January 2, 2013

Deploying Java Web-app using Maven on Tomcat 7

Following are the things you need to do

1) Add Maven Tomcat plugin

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <configuration>
                    <url>http://127.0.0.1:8080/manager/text</url>
                    <update>true</update>
                    <warFile>target/bday-rem.war</warFile>
                    <server>TomcatServer</server>
                    <path>/bday-rem</path>
                    <username>maven-user</username>
                    <password>password</password>
                </configuration>
            </plugin>   


Important thing to note here is the URL. From Tomcat 7  the deployment URL is changed to manager/text
User name and password are the fields that is used to do authorization and authentication in Tomcat

2)  Configure Authorization and Authentication in Tomcat

Add following in tomcat-users.xml file present in $TOMCAT_HOME/conf folder

<role rolename="manager-script"/>
<role rolename="manager-gui"/>
<user username="admin" password="password" roles="manager-gui"/>
<user username="maven-user" password="password" roles="manager-script"/>

Important thing to note here is that manager-gui and manager-script role cannot co-exist.

Please see following link for more information

http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html

No comments:

Post a Comment