This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Make script to install war files in Tomcat

 
Joe Harry
Ranch Hand
Posts: 10122
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Misha Ver
Ranch Hand
Posts: 470
 
Joe Harry
Ranch Hand
Posts: 10122
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess I asked about a Make script in Linux and not a maven plugin. Please read my post properly.
 
Misha Ver
Ranch Hand
Posts: 470
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10122
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10122
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 470
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you get an access to http://localhost:1979/manager/html with the credentials you are using?
 
Joe Harry
Ranch Hand
Posts: 10122
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10122
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic