Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/353.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法调用Tomcat管理器:服务器返回HTTP响应代码:401_Java_Tomcat_Deployment_Maven - Fatal编程技术网

Java 无法调用Tomcat管理器:服务器返回HTTP响应代码:401

Java 无法调用Tomcat管理器:服务器返回HTTP响应代码:401,java,tomcat,deployment,maven,Java,Tomcat,Deployment,Maven,我试图从maven将war部署到远程tomcat服务器,但在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/ma

我试图从maven将war部署到远程tomcat服务器,但在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
没有价值,我也不知道为什么

当我浏览此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>

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

我在博客上写了一篇文章,解释如何使用cargo:@JVerstry现在我使用简单的bash脚本,如下所示:它对jenkins更有用,帮助我在重新部署地狱时逃离permgen。我希望你也会喜欢:)
    <!-- 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>