web-dev-qa-db-fra.com

tomcat7-maven-plugin Code d'état de tomcatManager: 403, ReasonPhrase: Forbbiden

J'essaie de faire mvn clean package Tomcat7:deploy mais je reçois toujours cette erreur: tomcatManager status code:403, ReasonPhrase:Forbbiden

Mes configurations sont les suivantes:

~/.m2/settings.xml

<servers>
  <server>
    <id>localhost</id>
    <username>Tomcat</username>
    <password>s3cret</password>
  </server>
</servers>

pom.xml

  <profiles>
    <profile>
        <id>Tomcat-localhost</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <Tomcat-server>localhost</Tomcat-server>
            <Tomcat-url>http://localhost:8080/manager/html</Tomcat-url>
        </properties>
    </profile>
  </profiles>

  <build>
    <plugin>
        <groupId>org.Apache.Tomcat.maven</groupId>
        <artifactId>Tomcat7-maven-plugin</artifactId>
        <version>2.0</version>
        <configuration>
            <server>${Tomcat-server}</server>
            <url>${Tomcat-url}</url>
        </configuration>
      </plugin>
    </plugins>
  </build>

Tomcat-users.xml

  <role rolename="manager-gui"/>  
  <user username="Tomcat" password="s3cret" roles="manager-gui"/> 

Quelle est mon erreur? Parce que je ne le vois pas.

Erreur de message complète:

[INFO] --- Tomcat7-maven-plugin:2.0:deploy (default-cli) @ WebApp ---
[INFO] Deploying war to http://localhost:8080/Baskeitor  
Uploading: http://localhost:8080/manager/html/deploy?path=%2FWebApp
Uploaded: http://localhost:8080/manager/html/deploy?path=%2FWebApp (7985 KB at 50215.2 KB/sec)

[INFO] tomcatManager status code:403, ReasonPhrase:Prohibido
[INFO] <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
[INFO] <html>
[INFO]  <head>
[INFO]   <title>403 Access Denied</title>
[INFO]   <style type="text/css">
[INFO]     <!--
[INFO]     BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;font-size:12px;}
[INFO]     H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
[INFO]     PRE, TT {border: 1px dotted #525D76}
[INFO]     A {color : black;}A.name {color : black;}
[INFO]     -->
[INFO]   </style>
[INFO]  </head>
[INFO]  <body>
[INFO]    <h1>403 Access Denied</h1>
[INFO]    <p>
[INFO]     You are not authorized to view this page.
[INFO]    </p>
[INFO]    <p>
[INFO]     If you have already configured the Manager application to allow access and
[INFO]     you have used your browsers back button, used a saved book-mark or similar
[INFO]     then you may have triggered the cross-site request forgery (CSRF) protection
[INFO]     that has been enabled for the HTML interface of the Manager application. You
[INFO]     will need to reset this protection by returning to the
[INFO]     <a href="/manager/html">main Manager page</a>. Once you
[INFO]     return to this page, you will be able to continue using the Manager
[INFO]     appliction's HTML interface normally. If you continue to see this access
[INFO]     denied message, check that you have the necessary permissions to access this
[INFO]     application.
[INFO]    </p>
[INFO]    <p>
[INFO]     If you have not changed
[INFO]     any configuration files, please examine the file
[INFO]     <tt>conf/Tomcat-users.xml</tt> in your installation. That
[INFO]     file must contain the credentials to let you use this webapp.
[INFO]    </p>
[INFO]    <p>
[INFO]     For example, to add the <tt>manager-gui</tt> role to a user named
[INFO]     <tt>Tomcat</tt> with a password of <tt>s3cret</tt>, add the following to the
[INFO]     config file listed above.
[INFO]    </p>
[INFO] <pre>
[INFO] &lt;role rolename="manager-gui"/&gt;
[INFO] &lt;user username="Tomcat" password="s3cret" roles="manager-gui"/&gt;
[INFO] </pre>
[INFO]    <p>
[INFO]     Note that for Tomcat 7 onwards, the roles required to use the manager
[INFO]     application were changed from the single <tt>manager</tt> role to the
[INFO]     following four roles. You will need to assign the role(s) required for
[INFO]     the functionality you wish to access.
[INFO]    </p>
[INFO]     <ul>
[INFO]       <li><tt>manager-gui</tt> - allows access to the HTML GUI and the status
[INFO]           pages</li>
[INFO]       <li><tt>manager-script</tt> - allows access to the text interface and the
[INFO]           status pages</li>
[INFO]       <li><tt>manager-jmx</tt> - allows access to the JMX proxy and the status
[INFO]           pages</li>
[INFO]       <li><tt>manager-status</tt> - allows access to the status pages only</li>
[INFO]     </ul>
[INFO]    <p>
[INFO]     The HTML interface is protected against CSRF but the text and JMX interfaces
[INFO]     are not. To maintain the CSRF protection:
[INFO]    </p>
[INFO]    <ul>
[INFO]     <li>Users with the <tt>manager-gui</tt> role should not be granted either
[INFO]         the <tt>manager-script</tt> or <tt>manager-jmx</tt> roles.</li>
[INFO]     <li>If the text or jmx interfaces are accessed through a browser (e.g. for
[INFO]         testing since these interfaces are intended for tools not humans) then
[INFO]         the browser must be closed afterwards to terminate the session.</li>
[INFO]    </ul>
[INFO]    <p>
[INFO]     For more information - please see the
[INFO]     <a href="/docs/manager-howto.html">Manager App HOW-TO</a>.
[INFO]    </p>
[INFO]  </body>
[INFO] </html>

J'ai Tomcat 7.0.32 et je le redémarre toujours. Je modifie la configuration des utilisateurs ou de tout ce qui doit être chargé à nouveau.

24
Fran b

J'ai eu le même problème. Mais j'ai trouvé la solution suivante de ce problème:

pom.xml

<plugin>
    <groupId>org.Apache.Tomcat.maven</groupId>
    <artifactId>Tomcat7-maven-plugin</artifactId>
    <version>2.0</version>
    <configuration>
      <url>http://localhost:8080/manager/text</url>
      <server>localhost</server>
      <path>/${project.build.finalName}</path>
    </configuration>
</plugin>

~/.m2/settings.xml

<servers>
<server>
   <id>localhost</id>
   <username>admin</username>
   <password>s3cret</password>
</server>

Tomcat-users.xml

<role rolename="manager-script"/>
<user username="admin" password="s3cret" roles="manager-script"/>

Après avoir modifié Tomcat-users.xml n'oubliez pas de redémarrer le serveur. De même, n'attribuez pas le rôle manager-gui au rôle manager-script au même utilisateur.

63
Dzmitry

Assez pour faire comme ça 

pom.xml

<plugin>
  <groupId>org.Apache.Tomcat.maven</groupId>
  <artifactId>Tomcat7-maven-plugin</artifactId>
  <version>2.0</version>
  <configuration>
    <path>/mywebapp</path>
    <update>true</update>
    <url>http://localhost:8080/manager/text</url>
    <username>Tomcat</username>
    <password>Tomcat</password>
  </configuration>
</plugin> 

Tomcat-users.xml

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

De http://Tomcat.Apache.org/maven-plugin-2.0/index.html

Use http://localhost:8080/manager/text rather than the default Tomcat6 url.
5
Stas Yak

Cette erreur apparaîtra également si le même fichier WAR portant le même nom a déjà été déployé sur Tomcat.

3
Edgar Torres

L'URL n'est pas une utilisation correcte:

<Tomcat-url>http://localhost:8080/manager/html</Tomcat-url>
1
Olivier Lamy

Je voulais ajouter ceci en tant que commentaire, mais je n'ai pas assez de points de réputation pour le faire.

Ajouter ceci comme une réponse, car cela pourrait être utile pour quelqu'un. J'obtenais exactement les mêmes erreurs lorsque j'essayais de me déployer sur Tomcat7 à l'aide d'Eclipse et que je ne travaillais toujours pas après avoir essayé les solutions ci-dessus. Enfin, j'ai essayé d'utiliser Eclipse en ligne de commande (cmd) et cela a fonctionné à merveille. évidemment, je devais installer maven sur ma machine, puis définir la variable utilisateur M2_Home et la variable de chemin d'accès pointant vers M2_HOME/bin.

Merci. 

0
Nirmal Mangal

Il y a un malentendu sur le nom du rôle et la dernière partie de l'URL:

À l'origine, dans Tomcat-usres.xml , il n'y avait qu'un utilisateur "Tomcat" (rôle Tomcat), un utilisateur "les deux" (Tomcat + rôle1) mais aucun rôle d'administrateur. Il semble que la dernière partie de l'URL équivaut à nom de rôle dans certains aspects ...

Cela a fonctionné pour moi (sinon, j'ai toujours 403, même si le nom d'utilisateur + mot de passe est correct}):

<?xml version='1.0' encoding='utf-8'?>
<Tomcat-users>
  <role rolename="Tomcat"/>
  <role rolename="admin"/>
  <user username="Tomcat" password="Tomcat" roles="admin,Tomcat"/>
  <user username="admin" password="Tomcat" roles="admin,Tomcat"/>
</Tomcat-users>
0
hfrmobile