Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Deploy to Tomcat with Maven

 
Joe Harry
Ranch Hand
Posts: 10123
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

How could I instruct maven to deploy to local tomcat after building a war?
 
Joe Harry
Ranch Hand
Posts: 10123
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do I have to use the maven cargo plugin?? If yes, then how? Any suggestions?
 
Joachim Rohde
Ranch Hand
Posts: 433
Netbeans IDE
 
Joe Harry
Ranch Hand
Posts: 10123
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • 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 Harry
Ranch Hand
Posts: 10123
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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 Harry
Ranch Hand
Posts: 10123
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a war file.
 
Joachim Rohde
Ranch Hand
Posts: 433
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I meant, if you type "mvn tomcat:deploy" into your console, what does the output look like?
 
Joe Harry
Ranch Hand
Posts: 10123
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will run that today at home and paste the result here.
 
Joe Harry
Ranch Hand
Posts: 10123
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • 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 Harry
Ranch Hand
Posts: 10123
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do I have to start tomcat before I execute this maven goal?
 
Joe Harry
Ranch Hand
Posts: 10123
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • 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 Harry
Ranch Hand
Posts: 10123
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • 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,

 
Thomas Hatley
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic