Strictly Programming

Getting Started with Maven Tomcat Plug in

Posted in Maven by sqllyw on 02/10/2009


to check if tomcat is running:

ps -ef | grep java

getting mysql schema:

mysqldump –no-data -u user -ppassword dbname >schema.sql

Tomcat Plugin Home Page

Tomcat plugin is good for the deployment of servlet applications into a Tomcat server, it has three major functions:

  1. Deployment
  2. This is the functions I used often, I’d consider this as the most important functions of this plug in

  3. Container related goals
  4. Using this group of goals you can query the status of a running Tomcat server.

  5. Running an app in an embedded Tomcat Server
  6. This is very handy in development, you can run your app even you do not have a tomcat server installed, the embedded server is version 5.5.25 at the time of this writing

To get started you should have a servelet application based on Maven 2 running first, go to the directory of the application where pom.xml is located then try:

maven tomcat:run

pointing your browser at http://localhost:8080/myproject

You should see the program running. that’s the #3 feature listed above.

The easiest way to get started with Plugin is, have a tomcat running at port 8080, add a user ‘admin’ without password to $CATALINA_HOME/conf/tomcat_users.xml:

  <user username="admin" password="" roles="standard,manager"/>

try following container related goals:

mvn tomcat:info

mvn tomcat:list

To deploy your app:

mvn tomcat:deploy

mvn tomcat:redeploy

mvn tomcat:undeploy

Now the plug in is running, let’s do something more, I’d prefer to have a installed Tomcat Server running at port 80 and the embedded server at its default port 8080, with that, I can test my app first in the embedded server at port 8080 and deploy it later into the installed Tomcat server and test it in the port 80, of course you can choose whatever port number you like as long as the installed Tomcat server’s port is different from the embedded Tomcat’s port.

  1. update ./m2/settings.xml
  2. <servers>
        <server>
          <id>local_tomcat</id>
          <username>admin</username>
          <password></password>
        </server>
    </servers>
    
  3. Add this blog to pom.xml
  4. 		<plugin>
    		        <groupId>org.codehaus.mojo</groupId>
    		        <artifactId>tomcat-maven-plugin</artifactId>
    		        <version>1.0-beta-1</version>
    		        <configuration>
    		          <server>local_tomcat</server>
    		          <url>http://localhost:80/manager</url>
    		        </configuration>
    		 	</plugin>
    

    the entry in the settings.xml is actually to specify the user name and password while the port number is specified in the pom.xml’s url part.

About these ads

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: