简体   繁体   English

Tomcat 7 Manager 无法登录

[英]Tomcat 7 Manager can't login

Trying to log in but can't.尝试登录但无法登录。 My tomcat-users.xml, modified as I saw it here.我的 tomcat-users.xml,按照我在这里看到的进行修改。

    <?xml version="1.0" encoding="UTF-8"?>
   <tomcat-users>
      <role rolename="manager-gui"/>
      <role rolename="manager-script"/>
      <role rolename="manager-jmx"/>
      <role rolename="manager-status"/>
      <role rolename="admin-gui"/>
      <role rolename="admin-script"/>
      <user username="admin" password="admin" roles="manager-gui, manager-script, manager-jmx, manager-status, admin-gui, admin-script"/>
    </tomcat-users>

Any suggestions?有什么建议么?

Remove the spaces between the roles for admin/admin.删除 admin/admin 角色之间的空格。 The list should just be comma separated as so:该列表应该只是以逗号分隔,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users>
  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <role rolename="manager-jmx"/>
  <role rolename="manager-status"/>
  <role rolename="admin-gui"/>
  <role rolename="admin-script"/>
  <user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>
</tomcat-users>

I had the same issue but for me the reason was the server.xml file.我有同样的问题,但对我来说原因是server.xml文件。

Within the file there is a tag which specifies the path of the tomcat-users.xml :在文件中有一个标签,它指定了 tomcat-users.xml 的路径

  <GlobalNamingResources>
<!-- Editable user database that can also be used by
     UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
          type="org.apache.catalina.UserDatabase"
          description="User database that can be updated and saved"
          factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
          pathname="/etc/tomcat7/tomcat-users.xml" />

You have to make sure the pathname is set correctly to the location of your tomcat-users.xml file.您必须确保将路径名正确设置为您的tomcat-users.xml文件的位置。

还要检查它是否没有注释:

<!-- ... -->

You also need to restart Tomcat after making changes to tomcat-users.xml or server.xml , context.xml or web.xml for the changes to be effective.您还需要在对tomcat-users.xmlserver.xmlcontext.xmlweb.xml进行更改后重新启动 Tomcat 以使更改生效。

In my case, the problem was I did not restart Tomcat after making changes.就我而言,问题是我在进行更改后没有重新启动 Tomcat。 Also on Tomcat 7 I had assigned manager-script , manager-gui roles to the same user.同样在 Tomcat 7 上,我已将manager-scriptmanager-gui角色分配给同一用户。 So Tomcat gave 403 error to enforce CRSF protection.所以Tomcat给出了403错误来强制执行CRSF保护。

Wrong :错误

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

Correct :正确

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

Check the permissions and ownership on the file '/etc/tomcat7/tomcat-users.xml'.检查文件“/etc/tomcat7/tomcat-users.xml”的权限和所有权。 It should owned by root and group ownership should be tomcat7.它应该由 root 拥有,组所有权应该是 tomcat7。

-rw-r----- 1 root tomcat7 2101 Jan 22 10:34 tomcat-users.xml -rw-r----- 1 root tomcat7 2101 Jan 22 10:34 tomcat-users.xml

This is on Ubuntu 14.04.3 LTS, YMMV这是在 Ubuntu 14.04.3 LTS,YMMV 上

I had some problems with access Tomcat 's manager (v8.0) as part of NetBeans (v8.2) IDE under Windows 10 .我在访问Tomcat的管理器 (v8.0) 作为Windows 10下的NetBeans (v8.2) IDE 的一部分时遇到了一些问题。

The actual tomcat-users.xml file to add gui-manager user/password pairs is located at C:\\Users\\\\AppData\\Roaming\\NetBeans\\8.2\\apache-tomcat-8.0.27.0_base\\conf\\ path.用于添加 gui-manager 用户/密码对的实际tomcat-users.xml 文件位于 C:\\Users\\\\AppData\\Roaming\\NetBeans\\8.2\\apache-tomcat-8.0.27.0_base\\conf\\ 路径。 Open tomcat-users.xml file and add some rows:打开 tomcat-users.xml 文件并添加一些行:

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

After that you should restart Tomcat and try access manager again.之后,您应该重新启动 Tomcat 并再次尝试访问管理器。

Ubuntu Server 14.04.3 tomcat7 installed from repo从 repo 安装的 Ubuntu Server 14.04.3 tomcat7

What worked for me was removing the role definitions from the tomcat-users.xml file.对我有用的是从 tomcat-users.xml 文件中删除角色定义。 and then restarting tomcat.然后重启tomcat。

my file now looks like this:我的文件现在看起来像这样:

<tomcat-users>
<!--
  NOTE:  By default, no user is included in the "manager-gui" role required
  to operate the "/manager/html" web application.  If you wish to use this app,
  you must define such a user - the username and password are arbitrary.
    -->
<!--
  NOTE:  The sample user and role entries below are wrapped in a comment
  and thus are ignored when reading this file. Do not forget to remove
  <!.. ..> that surrounds them.
-->
  <user username="admin" password="n0tmyr3alp455w0rd" roles="manager-gui,admin-gui"/>
</tomcat-users>

Notice the instructions tell you to define the user who belongs to manager-gui but it does not tell you to define the role "manager-gui"请注意,说明告诉您定义属于 manager-gui 的用户,但并没有告诉您定义角色“manager-gui”

So if nothing else works for you check that here因此,如果没有其他方法适合您,请在此处查看

I had messed in my server.xml with the following line我在我的 server.xml 中使用了以下行

<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="jdbc/myapp"/>

That here should always be resourceName="UserDatabase"这里应该始终是resourceName="UserDatabase"

  <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>

I mistakenly thought it had to do with my applilcation database and have configured it.我错误地认为它与我的应用程序数据库有关并已对其进行了配置。 This here is the tomcat user database not the database that you have to your application.这是 tomcat 用户数据库,而不是您的应用程序所拥有的数据库。

尝试

sudo apt-get install tomcat7-admin

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

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