Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error 403 when try to deploy a maven project with tomcat-maven-plugin

I am trying deploy my project to tomcat7 using the Eclipse IDE, and I facing this error:

Uploading: http://localhost:8080/manager/html/deploy?path=%2Fexample
Uploaded: http://localhost:8080/manager/html/deploy?path=%2Fexample (13855 KB at 61573.5 KB/sec)

[ERROR] Tomcat return http status error: 403, Reason Phrase: Forbidden
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.259s
[INFO] Finished at: Sun Apr 20 09:44:18 GMT-03:00 2014
[INFO] Final Memory: 13M/223M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy (default-cli) on project example: Tomcat return http status error: 403, Reason Phrase: Forbidden: <html><head><title>Apache Tomcat/7.0.50 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 403 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>Access to the specified resource has been forbidden.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.50</h3></body></html> -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

My pom.xml have this configuration:

  <build>
  <plugins>
            <plugin>
              <groupId>org.apache.tomcat.maven</groupId>
              <artifactId>tomcat7-maven-plugin</artifactId>
              <version>2.2</version>
              <configuration>
                  <url>http://localhost:8080/manager/html</url>
                  <server>TomcatServer</server>
                  <path>/example</path>
                  <username>klebermo</username>
                  <password>[password]</password>
              </configuration>
            </plugin>
    </plugins>
    </build>

My tomcat-users.xml is that:

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="manager"/>
  <role rolename="admin"/>
  <user username="klebermo" password="[password]" roles="admin,manager"/>
</tomcat-users>

Anyone can point me what I doing wrong?

like image 820
Kleber Mota Avatar asked Mar 19 '23 20:03

Kleber Mota


1 Answers

the documentation mentions that the remote deployment commands should be sent to url manager/text, see here in Deploy A New Application Remotely.

by changing the configuration to that url instead, it should work:

<configuration>
    <url>http://localhost:8080/manager/text</url>
    ...
</configuration>

Also Tomcat has several pre-defined roles for doing certain tasks, try adding role manager-script:

<tomcat-users>
  <user username="tomcat" password="[password]" 
       roles="admin,manager,manager-script"/>
</tomcat-users>
like image 137
Angular University Avatar answered Apr 15 '23 02:04

Angular University