0


I'm trying auto deploy war file to apache-tomcat-server(6.0.33) using tomcat-maven-plugin6, but on tomcat:deploy command, maven(3.5.1/1.5.1.xxx EclipseIDE-embedded) is trying to install to incorrect URL (localhost:8080/webapplication), I have seen similar Q&A here (1,2) but it's answers does not solved my problem. Please find more details below.

Settings.xml

  <servers>
    <server>
      <id>localhost</id>
      <username>admin</username>
      <password>admin</password>
    </server>
  </servers>

pom.xml

<plugin>
    <groupId> org.apache.tomcat.maven</groupId>
    <artifactId>tomcat6-maven-plugin</artifactId>
    <version>2.0-beta-1</version>
    <configuration>
        <url>http://localhost:8080/manager</url>
        <!-- <username>usr</username> <password>pwd</password> -->
        <server>localhost</server>
        <path>/datatest</path>
        <warFile>target/service-manager.war</warFile>
    </configuration>
</plugin>

Maven Console:

[INFO] <<< tomcat-maven-plugin:1.1:deploy (default-cli) @ service-manager <<<
[INFO] 
[INFO] --- tomcat-maven-plugin:1.1:deploy (default-cli) @ service-manager ---
[INFO] Deploying war to http://localhost:8080/service-manager  
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Data manager ...................................... SUCCESS [  7.454 s]
[INFO] Business Manager .................................. SUCCESS [  0.109 s]
[INFO] Core module ....................................... SUCCESS [  6.699 s]
[INFO] Booter Application ................................ SUCCESS [  1.016 s]
[INFO] Booter Service Webapp ............................. FAILURE [ 33.289 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 49.099 s
[INFO] Finished at: 2015-08-09T16:09:15+05:30
[INFO] Final Memory: 21M/121M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project service-manager: Cannot invoke Tomcat manager: Server returned HTTP response code: 401 for URL: http://localhost:8080/manager/deploy?path=%2Fservice-manager&war= -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project service-manager: Cannot invoke Tomcat manager
Community
  • 1
  • 1
Nithin CV
  • 1,046
  • 9
  • 23
  • Setting both the `` and the `` probably confuses the plugin and causes it to ignore the `` mention (I agree - it shouldn't really have been coded that way). It looks like the `war` in your case is in the default location with the default name, so try removing the `` mention and see if it causes the `` setting to not be ignored. – mystarrocks Aug 09 '15 at 11:50

2 Answers2

0

I think the url should be http://localhost:8080/manager/text (you missed the /text).

Niklas P
  • 3,427
  • 2
  • 15
  • 19
  • I think for tomcat6: http://localhost:8080/manager and for tomcat7: http://localhost:8080/manager/text is the URL Please correct me if I am wrong. – Nithin CV Aug 10 '15 at 06:45
  • Sorry, you're right - /manager/text is the url for tomcat7. Sorry for that. I think @mystarrocks 's answer could be the right one - try NOT to use path and warFile in parallel. – Niklas P Aug 10 '15 at 08:10
0

I was having same behaviour and maybe you're trying to invoke the wrong maven goal.

First be sure your username and password are informed acoording to Tomcat conf/tomcat-users.xml configuration.

Second, if you are deploying on Tomcat 6, try using tomcat6:deploy or tomcat6:redeploy goal (instead of tomcat:deploy). Worked for me.

Some advices:

  • If it's not a requirement, better use last stable version of the plugin 2.2 http://tomcat.apache.org/maven-plugin-2.2/
  • I've never used warFile property, are you using it because there are several wars on target folder? If not, isn't necessary specify it.
exoddus
  • 2,230
  • 17
  • 27