tomcat7-maven-plugin tomcatmanager status code: 403, ReasonPhrase: Forbbiden

Próbuję zrobić mvn clean package tomcat7:deploy ale zawsze dostaję ten błąd: tomcatManager status code:403, ReasonPhrase:Forbbiden

Moje konfiguracje są następne:

~/.m2 / ustawienia.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-użytkownicy.xml

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

Jaki jest mój błąd? Bo tego nie widzę.

Complete message error:

[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>

Mam tomcat 7.0.32 i restartuję go zawsze zmieniam jakąś konfigurację o użytkownikach lub cokolwiek, co wymaga ponownego załadowania.

Author: Fran b, 2012-11-12

6 answers

Miałem ten sam problem. Ale znalazłem następujące rozwiązanie tego problemu:

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 / ustawienia.xml

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

Tomcat-użytkownicy.xml

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

Po zmianie Tomcat-users.xml nie zapomnij ponownie uruchomić serwera. Nie przypisuj również roli manager-gui z Manager-script do tego samego użytkownika.

 61
Author: Dzmitry,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-04-01 21:40:18

Enough to do like this

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-użytkownicy.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>

Z http://tomcat.apache.org/maven-plugin-2.0/index.html

Use http://localhost:8080/manager/text rather than the default tomcat6 url.
 5
Author: Stas Yak,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-06-25 11:22:30

Ten błąd pojawi się również, jeśli ta sama wojna o tej samej nazwie została już wdrożona do tomcat.

 3
Author: Edgar Torres,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-10-03 16:27:58

Url nie jest poprawny:

<tomcat-url>http://localhost:8080/manager/html</tomcat-url>
 1
Author: Olivier Lamy,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-11-12 08:50:58

Chciałem dodać to jako komentarz, ale nie mam wystarczającej liczby punktów reputacji, aby to zrobić.

Dodanie tego jako odpowiedzi, ponieważ może to być pomocne dla kogoś. Otrzymywałem dokładnie te same błędy podczas próby wdrożenia na tomcat7 za pomocą eclipse i nadal nie działał po wypróbowaniu powyższych rozwiązań. w końcu wypróbowałem poza eclipse używając wiersza poleceń (cmd) i zadziałało jak urok. oczywiście musiałem zainstalować Mavena na moim komputerze, a następnie ustawić zmienną użytkownika m2_home i zmienną PATH do M2_HOME / bin.

Dzięki.
 0
Author: Nirmal Mangal,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-11-27 15:37:47

Jest pewne nieporozumienie co do nazwy roli i ostatniej części URL:

Oryginalnie w tomcat-usres.xml był tylko użytkownik "tomcat" (rola tomcat), użytkownik "both" (tomcat + role1), ale bez roli administratora. Wydaje się, że ostatnia część adresu URL jest równa nazwie roli w pewnym aspekcie ...

To działało dla mnie ( w przeciwnym razie zawsze mam 403 nawet pod warunkiem poprawnego użytkownika + hasło):

<?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
Author: hfrmobile,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-12-11 09:29:17