gpt4 book ai didi

java - 无法调用 Tomcat 管理器 : Server returned HTTP response code: 401

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:00:34 25 4
gpt4 key购买 nike

我正尝试从 maven 向远程 tomcat 服务器部署 war,但我在 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]

我觉得很奇怪,war 没有任何值(value),我也不知道为什么。

当我浏览这个 URL 时,我在 Tomcat 的管理器中得到以下内容:

FAIL - Invalid context path null was specified

这是我的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>

服务器已在我的 maven setting.xml 中正确定义。

我做错了什么?

P.S.:我看过类似的question ,但它没有回答我遇到的问题。

解决方案

作为记录,我按照 Alexey 的建议修改了我的 pom.xml 并且它有效:

    <!-- 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>

最佳答案

尝试用户cargo控制 tomcat 和部署,这很简单,也很有效。

关于java - 无法调用 Tomcat 管理器 : Server returned HTTP response code: 401,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7489925/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com