Question

I'm trying to deploy a war with mvn tomcat:deploy and I get

Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project navigator-native: Cannot invoke Tomcat manager: Server returned HTTP response code: 401 for URL: ...//localhost:8080/manager/deploy? ...

I've already added the roles to tomcat-users.xml :

<role rolename="manager"/>
<role rolename="admin"/>
<user username="admin" password="password" roles="admin,manager"/>

But don't want to modify the project's POM.xml, so what is the default server used for the plugin? I've tried adding

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

but it doesn't work

Was it helpful?

Solution

Default url is http://localhost:8080/manager per Tomcat 6 maven plugin docs. Not sure if it's the same for tomcat 7.

For manager credentials, you add a server block to the ${user.home}/.m2/settings.xml file. Then you need to define the server ID by specifying the <server> element in the Tomcat plugin config, or on the command line:

mvn tomcat:deploy -Dmaven.tomcat.server=localhost <otherPropertiesHere>

The above assumes the server ID is "localhost" as shown in the original question.

OTHER TIPS

The id you're referring is the one in the plugin configuration, not the actual server, if you don't want to modify the pom's project either create a profile in the settings.xml file or pass the configuration in the command line:

mvn tomcat:deploy -Dmaven.tomcat.url=http://localhost/manager, also get sure you set -Dmaven.tomcat.update=true if you redeploy

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top