简体   繁体   English

Tomcat 9无法登录manager / html

[英]Tomcat 9 can't log into manager/html

I am unsure as to why I am unable to login, here are the permissions: 我不确定为什么无法登录,这里是权限:

<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">
<!--
  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. It is
  strongly recommended that you do NOT use one of the users in the commented out
  section below since they are intended for use with the examples web
  application.
-->
  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <role rolename="manager-gui"/>
  <role rolename="admin-gui"/>
  <role rolename="manager-script"/>
  <user username="lamidotijjo" password="s3cr3t" roles="manager-gui,manager-script,admin-gui"/>
  <user username="tomcat" password="<must-be-changed>" roles="tomcat"/>
  <user username="both" password="<must-be-changed>" roles="tomcat,role1"/>
  <user username="role1" password="<must-be-changed>" roles="role1"/>

</tomcat-users>

I installed it from the tomcat official website for Ubuntu yesterday. 我昨天从tomcat官方网站为Ubuntu安装了它。 I thought that all the permissions were correct. 我认为所有权限都是正确的。 Thanks! 谢谢!

All your permissions are correct, and the new user you added is fine. 您所有的权限都是正确的,您添加的新用户也可以。 The problem is that you did not set valid passwords on these three pre-configured users in file tomcat-users.xml : 问题是您没有在文件tomcat-users.xml中的这三个预配置用户上设置有效密码:

  <user username="tomcat" password="<must-be-changed>" roles="tomcat"/>
  <user username="both" password="<must-be-changed>" roles="tomcat,role1"/>
  <user username="role1" password="<must-be-changed>" roles="role1"/>

Tomcat deliberately configures those users with invalid passwords, forcing you to change them to something valid. Tomcat故意使用无效密码配置这些用户,从而迫使您将其更改为有效的密码。 If you check the log after starting Tomcat with those settings you probably see several stack traces similar to this: 如果使用这些设置启动Tomcat之后检查日志,则可能会看到一些类似于以下的堆栈跟踪:

10-Jun-2018 00:04:35.343 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 902 ms
10-Jun-2018 00:04:35.386 SEVERE [main] org.apache.tomcat.util.digester.Digester.fatalError Parse Fatal Error at line 48 column 34: The value of attribute "password" associated with an element type "user" must not contain the '<' character.
 org.xml.sax.SAXParseException; lineNumber: 48; columnNumber: 34; The value of attribute "password" associated with an element type "user" must not contain the '<' character.
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)

The error message is very explicit: 该错误消息非常明确:

The value of attribute "password" associated with an element type "user" must not contain the '<' character.

Just replace each instance of "<must-be-changed>" with "password" (or some password of your choice) and restart Tomcat to fix the problem. 只需用"password" (或您选择的某些密码)替换"<must-be-changed>"每个实例,然后重新启动Tomcat即可解决此问题。

Alternatively, you could just remove those three lines from the file (or comment them out) if you don't need those three users. 或者,如果不需要这三行,则可以从文件中删除这三行(或将其注释掉)。

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

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