Cannot invoke Tomcat manager: Server returned HTTP response code: 401
I am trying to deploy a war to a remote tomcat server from maven, but I get the following error in NetBeans:
Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli)
on project noca: Cannot invoke Tomcat manager:
Server returned HTTP response code: 401 for URL:
http://12.34.56.78/manager/html/deploy?path=%2Fnoca&war= -> [Help 1]
I find it strange that there is no value for war
and I don't know why.
When I browse this URL, I get the following in Tomcat's manager:
FAIL - Invalid context path null was specifi开发者_StackOverflowed
Here is my pom.xml
:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.test</groupId>
<artifactId>noca</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>6.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<server>Plasma01</server>
<url>http://12.34.56.78/manager/html</url>
</configuration>
</plugin>
</plugins>
</build>
</project>
The server is properly defined in my maven setting.xml
.
What am I doing wrong?
P.S.: I have seen this similar question, but it does not answer the issue I have.
SOLUTION
For the record, I modified my pom.xml
as following following Alexey's suggestion and it works:
<!-- plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<server>Plasma01</server>
<url>http://12.34.56.78/manager/html</url>
</configuration>
</plugin -->
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<container>
<containerId>tomcat6x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.tomcat.manager.url>
http://12.34.56.78/manager
</cargo.tomcat.manager.url>
<cargo.remote.username>xxxx</cargo.remote.username>
<cargo.remote.password>yyyy</cargo.remote.password>
</properties>
</configuration>
<deployer>
<type>remote</type>
<deployables>
<deployable>
<groupId>net.test</groupId>
<artifactId>noca</artifactId>
<type>war</type>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>
Try to user cargo to control tomcat and deployment, it's easy and worked.
精彩评论