简体   繁体   English

Maven Tomcat部署返回HTTP 403访问被拒绝,停止生产

[英]Maven Tomcat Deployment returns HTTP 403 Access Denied, halting production

I have configured a web app to be deployed from my development machine using maven, tomcat 7.0.42, on Ubuntu 12.04 with this build in my pom.xml: 我已将Web应用程序配置为在Ubuntu 12.04上使用maven tomcat 7.0.42从我的开发机器上部署,并在我的pom.xml中添加此版本:

<build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <warSourceDirectory>WebContent</warSourceDirectory>
                    <failOnMissingWebXml>true</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <configuration>
                    <url>http://SERVER-IP:8080/manager/html</url>
                    <server>server001</server>
                    <path>/FreeRide-Web</path>
                </configuration>
            </plugin>
        </plugins>
    </build>

Also, my settings.xml has this in it: 另外,我的settings.xml中包含以下内容:

<servers>
<server>
        <id>server001</id>
        <username>admin</username>
        <password>password</password>
    </server>
</severs>

however, when I run "mvn tomcat:deploy -e" it says: 但是,当我运行“ mvn tomcat:deploy -e”时,它说:

Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project FreeRide-Web: Cannot invoke Tomcat manager: Server returned HTTP response code: 403 for URL: http://166.78.166.149:8080/manager/html/deploy?path=%2FFreeRide-Web&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 FreeRide-Web: Cannot invoke Tomcat manager
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:318)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:414)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:357)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: org.apache.maven.plugin.MojoExecutionException: Cannot invoke Tomcat manager
    at org.codehaus.mojo.tomcat.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:149)
    at org.codehaus.mojo.tomcat.AbstractWarCatalinaMojo.execute(AbstractWarCatalinaMojo.java:70)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 20 more
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://166.78.166.149:8080/manager/html/deploy?path=%2FFreeRide-Web&war=
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1625)
    at org.codehaus.mojo.tomcat.TomcatManager.invoke(TomcatManager.java:604)
    at org.codehaus.mojo.tomcat.TomcatManager.deployImpl(TomcatManager.java:662)
    at org.codehaus.mojo.tomcat.TomcatManager.deploy(TomcatManager.java:295)
    at org.codehaus.mojo.tomcat.AbstractDeployWarMojo.deployWar(AbstractDeployWarMojo.java:85)
    at org.codehaus.mojo.tomcat.AbstractDeployMojo.invokeManager(AbstractDeployMojo.java:85)
    at org.codehaus.mojo.tomcat.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:141)
    ... 23 more

Yet, if I go to http://SERVER-IP:8080/manager/html in my browser and enter the username and password, it works. 但是,如果我在浏览器中转到http://SERVER-IP:8080/manager/html并输入用户名和密码,它就可以使用。 So I'm not quite sure what is going on. 所以我不太确定发生了什么。 Could anyone help me? 有人可以帮我吗?

I had the same issue sometime ago and managed to resolve. 不久前我遇到了同样的问题,并设法解决了。 You might need to modify the tomcat-users.xml to grant the correct roles for the user. 您可能需要修改tomcat-users.xml才能为用户授予正确的角色。

<user username="admin" password="xxxxxxx" roles="manager-script,manager-gui"/>

In the pom.xml I have manager/text rather than manager/html 在pom.xml中,我有manager / text而不是manager / html

<configuration>
  <path>/${project.build.finalName}</path>
  <url>http://localhost:8080/manager/text</url>
  <username>admin</username>
  <password>xxxxxx</password>
</configuration>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM