• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Deploy to Tomcat with Maven

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,

How could I instruct maven to deploy to local tomcat after building a war?
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do I have to use the maven cargo plugin?? If yes, then how? Any suggestions?
 
Ranch Hand
Posts: 433
Netbeans IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://mojo.codehaus.org/tomcat-maven-plugin/deployment.html
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That was not so informative. It tried that and it did not work. I mean after executing mvn:tomcat deploy nothing happened.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does the following mean?



By path, do they mean that it is the path of the war file? I guess yes and the war file that I have is generated under the target folder of my web project. So does that mean I specify the target folder location and it is a folder that normally gets rewirtten when I say mvn clean:deploy....Can anyone throw some lights on this?
 
Joachim Rohde
Ranch Hand
Posts: 433
Netbeans IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jothi Shankar Kumar wrote:I mean after executing mvn:tomcat deploy nothing happened.


What does the output of Maven look like?
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's a war file.
 
Joachim Rohde
Ranch Hand
Posts: 433
Netbeans IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, I meant, if you type "mvn tomcat:deploy" into your console, what does the output look like?
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I will run that today at home and paste the result here.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here it is,

[INFO] Webapp assembled in[125 msecs]
[INFO] Building war: D:\My Projects\MyWebApp\web\targ
et\MyWeb.war
[INFO] [tomcat:deploy {execution: default-cli}]
[INFO] Deploying war to http://localhost:8080/web
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Cannot invoke Tomcat manager

Embedded error: Connection refused: connect
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9 seconds
[INFO] Finished at: Mon Nov 23 21:46:41 CET 2009
[INFO] Final Memory: 19M/35M
[INFO] ------------------------------------------------------------------------

 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do I have to start tomcat before I execute this maven goal?
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did start tomcat and it worked. Now I'm trying to get that done using IntelliJ. Will post if I hit any problems.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Allright that seems to work as well. But it seems to not pick the correct war file. I do not know from where it places the web.war. My war file is actually MyWeb.war. Here is what I have for the build configuration.



The above mentioned entry isin the parent pom of the web project. The pom in my web project has the following entry,

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings Jothi -

Not sure if you're still having issues with this, but if you're doing a standard build/package where the war is being put into the <project_home>/target folder, I'd suggest removing the optional <warFile> element and allowing the tomcat-plugin to use the default settings. This seems to work quite well for me, using a mvn clean tomcat:redeploy will build and push up the new war. Which reminds me, using the 'clean' goal prior to any build is a good practice to get into, as it assures that you're getting the freshest bits.

My current configuration is:


Keep in mind that by default the tomcat-plugin will expect your manager login to be "admin' "<blank>", in other words the user is 'admin' and there is no password set....these are configured in the <tomcat_home>/conf/tomcat-users.xml file.

Hope this helps someone!
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic