首页 文章

tomcat-maven-plugin 403错误

提问于
浏览
34

当我使用mvn tomcat:tomcat-maven-plugin的部署时出现403错误:

无法在项目my-webapp上执行目标org.codehaus.mojo:tomcat-maven-plugin:1.0:deploy(default-cli):无法调用Tomcat管理器:服务器返回HTTP响应代码:403 for URL: http://localhost:8080/manager/text/deploy?path=%2Fdms&war=

我认为这是因为空战参数 . 但为什么它是空的???

在pom.xml中有:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>tomcat-maven-plugin</artifactId>

  <configuration>
    <warFile>target\my-webapp.war</warFile>
    <server>myserver</server>
    <url>http://localhost:8080/manager/text</url>
    <path>/dms</path>
  </configuration>
</plugin>

21 回答

  • 0

    这也是可能的:

    <plugin>
       <groupId>org.codehaus.mojo</groupId>
       <artifactId>tomcat-maven-plugin</artifactId>
        <configuration>
            <server>myserver</server>
            <username>admin</username>
            <password>admin</password>
        </configuration>
    </plugin>
    
  • 3

    如果您使用Tomcat 7,则需要引用tomcat插件中的url http://localhost:8080/manager/html .

    http://mojo.codehaus.org/tomcat-maven-plugin/examples/deployment-tomcat7.html

    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>tomcat-maven-plugin</artifactId>
      <version>1.2-SNAPSHOT</version>
      <configuration>
        <url>http://localhost:8080/manager/html</url>
      </configuration>
    </plugin>
    
  • 0

    /manager 应用程序默认由用户名/密码保护 . 如果输入http://localhost:8080/manager,则还会要求您提供安全凭证 . 首先在Tomcat中创建/启用用户:取消或几次尝试失败后,Tomcat将在错误屏幕上提供帮助 . 然后在 tomcat-maven-plugin 中使用这些凭据,如here所述:

    将一个插件配置块添加到您的pom.xml:

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>tomcat-maven-plugin</artifactId>
        <configuration>
                <server>myserver</server>
        </configuration>
    </plugin>
    

    将相应的服务器块添加到settings.xml:

    <server>
        <id>myserver</id>
        <username>myusername</username>
        <password>mypassword</password>
    </server>
    
  • 6

    你应该使用/ text:

    HTTP://本地主机:8080 /经理/文

    并添加到用户角色管理器脚本

  • 0

    您使用的是tomcat 7,您应该将插件配置保留在pom.xml中,如下所示:

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>tomcat-maven-plugin</artifactId>
        <configuration>
            <url>http://localhost:8080/manager/html</url>
            <server>tomcat</server>
            <path>/finance</path>
        </configuration>
    </plugin>
    

    我已尝试使用版本配置,如上例所示,但它对我不起作用 . 在settings.xml中,shoud具有服务器的配置,与pom.xml中的值匹配

    <settings>
        <servers>
            <server>
                <id>tomcat</id>
                <username>admin</username>
                <password>admin</password>
            </server>
        </servers>
    </settings>
    

    所以,mvn tomcat:deploy或mvn tomcat:redeploy(如果你已经部署了app),或者mvn tomcat:run(用tomcat down)应该可以工作 .

  • 7

    你只需要通过添加"/html"来更改网址,这样它就像这个http://localhost:8080/manager/html和bingo它的工作希望有帮助

  • 8

    对于Tomcat7,在tomcat-users.xml中,您还需要rolename manager-script

    <role rolename="manager-gui"/>
    <role rolename="manager-script"/>
    <user username="tomcat" password="s3cret" roles="manager-script,manager-gui"/>
    

    在项目的POM.xml中

    <plugin>
       <groupId>org.codehaus.mojo</groupId>
       <artifactId>tomcat-maven-plugin</artifactId>
       <configuration>
            <url>http://localhost:8080/manager/text</url>
            <server>myserver</server>
            <path>/sw</path>
       </configuration>
    </plugin>
    

    和maven的settings.xml:

    <servers>
     <server>
      <id>myserver</id>
      <username>tomcat</username>
      <password>s3cret</password>
     </server>
    </servers>
    
  • 0

    必须确保完成一些步骤 . 这可能是一个真正的黑洞 .

    如果您正在使用org.codehaus.mojo中的tomcat-maven-plugin,则必须使用以下配置:

    <configuration>
        <url>http://localhost:8080/manager/text</url>
        <warFile>your_war_filename.war</warFile>
        <server>server_name_on_settingsxml</server>
    </configuration>
    

    请确保您在maven settings.xml上定义了“server_name_on_settingsxml”服务器凭据 . 使用mvn tomcat:deploy(你必须使用这个'tomcat'前缀),这是读取部署上述配置的唯一方法 .

    但是,如果您使用org.apache.tomcat.maven中的tomcat7-maven-plugin,则必须使用mvn tomcat7:deploy . 'tomcat7'前缀将从插件中读取配置:

    <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
    

    我正在使用tomcat:deploy,我在pom.xml上定义了tomcat7-maven-plugin . 所以,maven部署从未读过我的配置标签......

    如果您确保正确定义了用户名和密码,并且在部署时使用了正确的插件,那么它将起作用 .

  • 6

    如果您尝试使用codehouse tomcat插件版本1.1在Tomcat 7服务器上进行部署,则可能会出现403错误 . 版本1.1尚不支持Tomcat 7 .

    如果您使用的是Tomcat 7,则应使用Cargo .

  • 1

    如果您使用的是Tomcat 7:

    • 在pom.xml中更改配置以使用插件的Tomcat 7版本
    <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.1</version>
        <configuration>
            <url>http://127.0.0.1:8080/manager/html</url>
            <server>TomcatServer</server>
            <path>/your_context</path>
            <username>some_user_name</username>
            <password>some_password</password>
        </configuration>
    </plugin>
    

    注意和值 - 它们与Tomcat 6的不同 .

    • 不要忘记在脚本中将"tomcat:deploy"更改为"tomcat7:deploy",或在Eclipse中将外部工具配置启动器更改为"tomcat:deploy" .

    • 将服务器配置添加到settings.xml,通常位于.m2文件夹下

    <server>

    <ID> TomcatServer </ ID>
    <用户名> some_user_name </用户名>
    <密码> some_password </密码>
    </服务器>

    • 如果您需要其他选项,例如部署位于非标准文件夹中的WAR文件,请访问:Tomcat 7 Maven Plugin
  • 2

    我发现我必须使用以下字符串而不是“html”:

    http://localhost:8080/manager/text
    
  • 14

    如果您使用的是版本7,则有一个问题:默认情况下不启用对/ manager / text资源的访问 .

    您必须使用角色mananger-script创建一个用户,如documentation中所述

    It would be quite unsafe to ship Tomcat with default settings that allowed anyone
    on the Internet to execute the Manager application on your server.
    Therefore, the Manager application is shipped with the requirement that anyone
    who attempts to use it must authenticate themselves, using a username and
    password that have the role manager-script associated with them.
    Further, there is no username in the default users file
    ($CATALINA_BASE/conf/tomcat-users.xml) that is assigned this role.
    Therefore, access to the Manager application is completely disabled by default.
    
    To enable access to the Manager web application, you must either create a new
    username/password combination and associate the role name manager-script with it,
    or add the manager-script role to some existing username/password combination.
    

    希望能帮助到你 :)

  • 1

    我曾经得到同样的错误,你只需要确保tomcat-users.xml文件包含用户(在我的情况下是admin),角色为(manager,manager-gui,admin,manager-script) .

    我在ubuntu上有tomcat 7,maven 3 .

  • 44

    您只需要在config文件夹的tomcat-users.xml中将manager-script和manager角色添加到tomcat用户 . 在Tomcat 7中,您必须为不同的角色指定不同的角色管理器GUI访问,在这种情况下转到文本 . 在文本界面的最后,您必须使用经理脚本角色 .

  • 0

    也许你应该在〜/ .m2 / settings.xml中检查你的配置文件,这个文件必须是跟随struct:

    <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                          http://maven.apache.org/xsd/settings-1.0.0.xsd">
      <localRepository/>
      <interactiveMode/>
      <usePluginRegistry/>
      <offline/>
      <pluginGroups/>
      <servers/>
      <mirrors/>
      <proxies/>
      <profiles/>
      <activeProfiles/>
    </settings>
    

    之后,您应该确保您的服务器conf对于您的项目是正确的,例如:

    <servers>
         <server>
            <id>mytomcat</id>
            <username>test</username>
            <password>test</password>
         </server>
      </servers>
    

    以后运行mvn tomcat:deploy . 还记得你也可以运行tomcat:deploy -X来查看debbug .

  • 3

    此解决方案适用于“Apache”Tomcat7插件:如前所述,您需要在网址末尾添加“/ text”

    <plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <port>8080</port>
        <path>/deployPath</path>
        <url>http://localhost:8080/manager/text</url>
        <server>TomcatServer</server>
    </configuration>
    

    配置位于.m2文件夹内的“settings.xml”

    <servers>
        <server>
            <id>TomcatServer</id>
            <username>script-admin</username>
            <password>password</password>
        </server>
    </servers>
    

    由于您使用的是Tomcat 7,因此最重要的是您应该为“manager-script”角色创建一个不同的用户,正如文档中提到的那样!

    <role rolename="manager-script"/>
    <user username="tomcat" password="password" roles="manager-script"/>
    
  • 27

    如果您遇到有关用户名和密码的问题,请不要担心,tomcat目录中有一个名为 tomcat-user.xml 的文件,去那里查看名称和密码属性,并在提示询问用户名和密码时使用 .

    如果还是你无法打开apache主页做一件事,在tomcat目录下还有另一个名为 server.xml 的文件go并将端口8080改为此

  • 4

    如果您使用带有插件m2eclipse的Eclipse,并且在尝试这些解决方案后仍然存在此错误,则可能是因为此插件未包含管理器 . 您应该单独下载Tomcat并配置Eclipse以使用它(请查看此链接:tomcat-maven-plugin: Server returned HTTP response code: 403

  • 2

    从tomcat6传递到tomcat7回顾:

    • 在tomcat-user.xml中添加角色

    • 将/ text或/ html添加到您的网址

    • 更改插件版本

    <groupId>org.apache.tomcat.maven</groupId> 
    <artifactId>tomcat7-maven-plugin</artifactId> 
    <version>2.2</version>
    
    • 更改选项tomcat:使用tomcat7:deploy进行部署
  • 8

    在尝试将Web应用程序部署到与Netbeans捆绑在一起的Tomcat Server 8.0上时,我花了三天时间在_1700537上 . 当我在命令行上使用 mvn tomcat7:deploy 时,一切都很完美,但是通过Netbeans IDE没有成功 . 我在POM.xml中设置了tomcat maven插件

    <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <configuration>
            <url>http://localhost:8080/manager/text</url>
            <server>tomcat</server>
        </configuration>
    </plugin>
    

    加上Maven的.m2 / conf / settings.xml中的服务器记录,

    <settings>
        <servers>
            <server>
                <id>tomcat</id>
                <username>admin</username>
                <password>admin</password>
            </server>
        </servers>
    </settings>
    

    在tomcat-users.xml中甚至适当的tomcat用户

    <role rolename="manager-gui"/>
    <role rolename="manager-script"/>
    <user username="tomcat" password="tomcat" roles="manager-script,manager-gui"/>
    

    但仍然没有成功 . 根本原因是我们公司使用的代理服务器和Netbeans设置 . In Netbeans, go to Tools -> Options and on General tab, use Manual Proxy Settings instead of System Proxy Settings (即使系统代理设置有效) . 它帮助了我,现在我可以直接从Netbeans在Tomcat 8上部署Web应用程序 . 您还可以在仅使用localhost服务器时设置“无代理” . 我的麻烦的根本原因是在默认Web浏览器中设置了错误的代理,这是选项系统代理设置的来源 .

  • 1

    我也得到了403错误,但只有当我通过Apache 2连接时 . 当我使用端口8080并直接部署到tomcat时它可以工作 . 所以: try to add port 8080 to the URL

    我仍在试图弄清楚为什么它不能通过Apache工作 . 我正在使用 ProxyPass / ajp://localhost:8009/

    <Location "/manager" >
         Order allow,deny
         Allow from 62.245.147.202
         Satisfy Any
       </Location>
    

相关问题