aspose file tools*
The moose likes Linux / UNIX and the fly likes Make script to install war files in Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Make script to install war files in Tomcat" Watch "Make script to install war files in Tomcat" New topic
Author

Make script to install war files in Tomcat

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9349
    
    2

Guys,

I would like to automate the following process:

(1) call mvn clean install on my project
(2) stop the Tomcat instance if already running
(3) after Tomcat is stopped, delete the war from its webapp directory
(4) copy the war file from the specific location of my project
(5) start Tomcat

I guess this is the task that is usually done by the scm guys. I would like to try this out by myself. Suggestions and ideas needed.


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
http://mojo.codehaus.org/tomcat-maven-plugin/
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9349
    
    2

I guess I asked about a Make script in Linux and not a maven plugin. Please read my post properly.
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
I assume your goal is deploying, redeploying, and undeploying Tomcat applications. The plugin is exactly what you needed. You could call all mvn command from Linux's shell script.
By the way you do not need start/stop Tomcat to deploy or undeploy an application.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9349
    
    2

Yes, you are right. My goal is just that but I also would like to combine this with starting, stopping and restarting Tomcat. From my previous experiences, I've seen the configuration management guys doing a make script or a shell script to automate this... be it Maven or Ant.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9349
    
    2

Ok. So I have my configuration for Maven build to deploy to Tomcat as follows.



I also have the following user and password defined in tomcat-users.xml file.



But when I run mvn:tomcat deploy I get an exception as below:


Help appreciated.


Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Can you get an access to http://localhost:1979/manager/html with the credentials you are using?
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9349
    
    2

There was a small mistake form my side in issuing the user name and password. Got to get it working now.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9349
    
    2

Just writing down the steps so that it could serve as a reference for anyone:

Step 1: Add the following to the build element of your master pom.xml of your project:



Step 2: Create the user in tomcat-users-xml for the user that we used in our pom.xml as in step 1 above



Step 3: Start Tomcat manually

Step 4: Call mvn package tomcat:deploy or mvn package tomcat:redeploy from your top most project pom.xml file
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Make script to install war files in Tomcat