Tomcat 身份验证失败 - 401 未授权

Tomcat 身份验证失败 - 401 未授权

尝试访问 Tomcat 管理控制台(Apache Tomcat/8.0.50)时出现错误。

警告 [http-apr-8080-exec-7] org.apache.catalina.realm.LockOutRealm.filterLockedAccounts 已尝试验证锁定的用户“admin”

我更改了配置文件“tomcat-users.xml”并重新启动了 tomcat

<tomcat-users xmlns="http://tomcat.apache.org/xml"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
              version="1.0">
<user username="admin" password="!w@B@#7XTFj" roles="manager-gui,admin-gui" />

server.xml 中有关“realm”的信息

<Realm className="org.apache.catalina.realm.LockOutRealm">
        <!-- This Realm uses the UserDatabase configured in the global JNDI
             resources under the key "UserDatabase".  Any edits
             that are performed against this UserDatabase are immediately
             available for use by the Realm.  -->
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

以及关于“资源”

<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="conf/tomcat-users.xml" />
                     <Resource name="jdbc/ERS"
                        auth="Container"
                        type="javax.sql.DataSource"
                        driverClassName="oracle.jdbc.OracleDriver"
                        url="jdbc:oracle:thin:@servername:port:BDD_name"
                        username="SAU_BIS"
                        password="V0t0,z91!"
                        maxActive="100000"
                        maxIdle="100000"  />
  </GlobalNamingResources>

我添加了 loglvel:org.apache.catalina.realm.level = FINE 并且我有以下信息:

13-Mar-2020 08:19:08.515 FINE [http-apr-8080-exec-4] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[JMX Proxy interface]' against GET /status --> false
13-Mar-2020 08:19:08.515 FINE [http-apr-8080-exec-4] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[Status interface]' against GET /status --> true
13-Mar-2020 08:19:08.515 FINE [http-apr-8080-exec-4] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[HTML Manager interface (for humans)]' against GET /status --> false
13-Mar-2020 08:19:08.515 FINE [http-apr-8080-exec-4] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[Text Manager interface (for scripts)]' against GET /status --> false
13-Mar-2020 08:19:08.515 FINE [http-apr-8080-exec-4] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[JMX Proxy interface]' against GET /status --> false
13-Mar-2020 08:19:08.515 FINE [http-apr-8080-exec-4] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[Status interface]' against GET /status --> true
13-Mar-2020 08:19:08.515 FINE [http-apr-8080-exec-4] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[HTML Manager interface (for humans)]' against GET /status --> false
13-Mar-2020 08:19:08.515 FINE [http-apr-8080-exec-4] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[Text Manager interface (for scripts)]' against GET /status --> false
13-Mar-2020 08:19:08.515 FINE [http-apr-8080-exec-4] org.apache.catalina.realm.RealmBase.hasUserDataPermission   User data constraint has no restrictions
13-Mar-2020 08:19:24.345 FINE [http-apr-8080-exec-5] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[JMX Proxy interface]' against GET /status --> false
13-Mar-2020 08:19:24.345 FINE [http-apr-8080-exec-5] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[Status interface]' against GET /status --> true
13-Mar-2020 08:19:24.345 FINE [http-apr-8080-exec-5] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[HTML Manager interface (for humans)]' against GET /status --> false
13-Mar-2020 08:19:24.345 FINE [http-apr-8080-exec-5] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[Text Manager interface (for scripts)]' against GET /status --> false
13-Mar-2020 08:19:24.345 FINE [http-apr-8080-exec-5] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[JMX Proxy interface]' against GET /status --> false
13-Mar-2020 08:19:24.345 FINE [http-apr-8080-exec-5] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[Status interface]' against GET /status --> true
13-Mar-2020 08:19:24.345 FINE [http-apr-8080-exec-5] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[HTML Manager interface (for humans)]' against GET /status --> false
13-Mar-2020 08:19:24.345 FINE [http-apr-8080-exec-5] org.apache.catalina.realm.RealmBase.findSecurityConstraints   Checking constraint 'SecurityConstraint[Text Manager interface (for scripts)]' against GET /status --> false
13-Mar-2020 08:19:24.345 FINE [http-apr-8080-exec-5] org.apache.catalina.realm.RealmBase.hasUserDataPermission   User data constraint has no restrictions
13-Mar-2020 08:19:24.361 FINE [http-apr-8080-exec-5] org.apache.catalina.realm.CombinedRealm.authenticate Attempting to authenticate user "admin" with realm "org.apache.catalina.realm.UserDatabaseRealm"
13-Mar-2020 08:19:24.361 FINE [http-apr-8080-exec-5] org.apache.catalina.realm.CombinedRealm.authenticate Failed to authenticate user "admin" with realm "org.apache.catalina.realm.UserDatabaseRealm"

但仍然无法在控制台上访问。

有任何想法吗 ?

答案1

它说用户名“admin”已被锁定,将用户名更改为其他任何名称并重新启动 tomcat 服务器。

相关内容