Tomcat 无法登录到manager app

我又来麻烦大家了 在网上搜出来的东西试了几个都不管用
系统版本 是 42.1 的
tomcat 版本见图



tomcat /conf/tomcat-user.xml 配置文件为:

<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<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.
-->
<!--
  NOTE:  The sample user and role entries below are intended for use with the
  examples web application. They are wrapped in a comment and thus are ignored
  when reading this file. If you wish to configure these users for use with the
  examples web application, do not forget to remove the <!.. ..> that surrounds
  them. You will also need to set the passwords to something appropriate.
-->
<!--
  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <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>
  <role rolename="admin"/> 
  <role rolename="admin-gui"/>
  <role rolename="admin-script"/>
  <role rolename="manager"/>
  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <role rolename="manager-jmx"/>
  <role rolename="manager-status"/>
  <user name="admin" password="tomcat" roles="admin,manager,admin-gui,admin-script,manager-gui,manager-script,manager-jmx,manager-status" /> -->
</tomcat-users>

在 /usr/local/tomcat/apache-tomcat-8.5.4/bin> ./startup.sh
登录 localhost:8080/manager/html 用 admin 密码 tomcat 怎么也登录不进去
请问这个原因出在哪里呢 谢谢了




我认为是:你的 tomcat-users.xml 文件的倒数第二行,你在定义 admin 用户的哪一行后面有一个注释的关闭标签没有删掉,导致你的真个 xml 文件有语法错误,所以这个文件没有被 tomcat 正确的读取。所以在 tomcat 启动以后,服务器里面没有相应的用户。建议你修改我说的地方,然后重启 tomcat。

修改成这样 还是无法登录~~~~~~~~~~`

改了也不行啊

改了之后重启 tomcat 了吗?

改完之后重启了 还是不行 郁闷了~ :sweat:

那就只能查看一下 tomcat 的日志,看到底是哪里出错了!! 我觉得像这张情日志当中应该有记录!!

9 月 6 号 今天的日志看不到什么内容 截图是今天日志的



下面的是 9 月 5 号 localhost_access_log.2016-09-05.txt 里面的日志内容

127.0.0.1 - - [05/Sep/2016:07:07:11 +0800] "GET / HTTP/1.1" 200 11248
127.0.0.1 - - [05/Sep/2016:07:07:11 +0800] "GET /tomcat.css HTTP/1.1" 200 5576
127.0.0.1 - - [05/Sep/2016:07:07:11 +0800] "GET /tomcat.png HTTP/1.1" 200 5103
127.0.0.1 - - [05/Sep/2016:07:07:11 +0800] "GET /bg-nav.png HTTP/1.1" 200 1401
127.0.0.1 - - [05/Sep/2016:07:07:11 +0800] "GET /asf-logo.png HTTP/1.1" 200 17811
127.0.0.1 - - [05/Sep/2016:07:07:11 +0800] "GET /bg-upper.png HTTP/1.1" 200 3103
127.0.0.1 - - [05/Sep/2016:07:07:11 +0800] "GET /bg-button.png HTTP/1.1" 200 713
127.0.0.1 - - [05/Sep/2016:07:07:11 +0800] "GET /bg-middle.png HTTP/1.1" 200 1918
127.0.0.1 - - [05/Sep/2016:07:07:11 +0800] "GET /favicon.ico HTTP/1.1" 200 21630
127.0.0.1 - - [05/Sep/2016:07:08:36 +0800] "GET /docs/ HTTP/1.1" 200 16578
127.0.0.1 - - [05/Sep/2016:07:08:36 +0800] "GET /docs/images/docs-stylesheet.css HTTP/1.1" 200 5780
127.0.0.1 - - [05/Sep/2016:07:08:36 +0800] "GET /docs/images/tomcat.png HTTP/1.1" 200 8410
127.0.0.1 - - [05/Sep/2016:07:08:36 +0800] "GET /docs/images/asf-feather.png HTTP/1.1" 200 40042
127.0.0.1 - - [05/Sep/2016:07:08:36 +0800] "GET /docs/images/fonts/fonts.css HTTP/1.1" 200 1943
127.0.0.1 - - [05/Sep/2016:07:08:36 +0800] "GET /docs/images/fonts/OpenSans700.woff HTTP/1.1" 200 22748
127.0.0.1 - - [05/Sep/2016:07:08:36 +0800] "GET /docs/images/fonts/OpenSans400italic.woff HTTP/1.1" 200 21092
127.0.0.1 - - [05/Sep/2016:07:22:24 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:07:22:41 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:07:22:41 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:07:30:32 +0800] "GET /docs/introduction.html HTTP/1.1" 200 11846
127.0.0.1 - - [05/Sep/2016:07:36:30 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:07:36:39 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:07:36:49 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:07:37:22 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:07:37:31 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:07:37:37 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:07:41:13 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:07:41:21 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:07:41:28 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:07:44:04 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:07:44:12 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:07:44:13 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:07:44:30 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:07:44:31 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:07:44:32 +0800] "GET /favicon.ico HTTP/1.1" 200 21630
127.0.0.1 - - [05/Sep/2016:07:58:20 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:07:58:41 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:07:58:41 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:07:58:41 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:01:09 +0800] "GET / HTTP/1.1" 200 11248
127.0.0.1 - - [05/Sep/2016:08:01:15 +0800] "GET /docs/manager-howto.html HTTP/1.1" 200 72727
127.0.0.1 - - [05/Sep/2016:08:01:47 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:01:47 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:01:47 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:01:47 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:01:47 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:01:47 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:01:47 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:01:47 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:01:48 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:01:48 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:01:48 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:01:48 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:01:48 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:01:48 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:01:48 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:01:48 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:01:48 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:01:48 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:01:48 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:01:48 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:01:55 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:04:36 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:04:47 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:10:34 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:10:42 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:11:00 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:11:00 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:11:13 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:11:13 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:11:13 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:22:15 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:22:23 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:24:33 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:24:40 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:36:24 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:36:24 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:36:28 +0800] "GET /favicon.ico HTTP/1.1" 200 21630
127.0.0.1 - - [05/Sep/2016:08:38:17 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:38:24 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:38:33 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:08:41:07 +0800] "GET / HTTP/1.1" 200 11248
127.0.0.1 - - [05/Sep/2016:08:41:11 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:11:25:57 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:11:29:09 +0800] "GET /manager/html HTTP/1.1" 401 2473
127.0.0.1 - - [05/Sep/2016:11:29:34 +0800] "GET /manager/html HTTP/1.1" 401 2473

9 月 5 号 host-manager.2016-09-05.log 内容同样是空的

你能看出原因在哪里吗? :question:

401,认证错误,八成是你的配置文件语法有错误,把你的整个配置文件拷到 tool.oschina.net/codeformat/xml 格式化,看看有什么错误?

1赞

还有这么好的网站!!!学习了!!

错误内容: error on line 55 document: xml document structures must start and within the same entity nested exception:xml document structures must start and end withinthe same entity
这意思是 代码格式上在最后哪里有问题? 我改来改去还是不行… :nauseated_face:

<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<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.
-->
<!--
  NOTE:  The sample user and role entries below are intended for use with the
  examples web application. They are wrapped in a comment and thus are ignored
  when reading this file. If you wish to configure these users for use with the
  examples web application, do not forget to remove the <!.. ..> that surrounds
  them. You will also need to set the passwords to something appropriate.
-->
<!--
  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <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>
  <role rolename="admin"/> 
  <role rolename="admin-gui"/>
  <role rolename="admin-script"/>
  <role rolename="manager"/>
  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <role rolename="manager-jmx"/>
  <role rolename="manager-status"/>
  <user name="admin" password="tomcat" roles="admin,manager,admin-gui,admin-script,manager-gui,manager-script,manager-jmx,manager-status" />
  
</tomcat-users>


我改成这样:<?xml version="1.0" encoding="utf-8"?>

他竟然没有错误提示了

非常感谢你提供的这个网站 问题搞定了
虽然我不懂什么编程语言 不过经过各种的测试 还是让我把问题点搞定了 谢谢你 :heart_eyes: :heart_eyes: :heart_eyes: :smirk:
上几个图~






因为上面已经有了 tomcat-users 的开始节点

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

所以删掉下面的 tomcat-users 开始节点就好了,你多写了一个开始节点。

嗯 是的 多谢你提供的这个网址 :heart_eyes: 我起初不知道原因在哪里 然后就逐行逐段的测试文件里面的代码块 终于让偶发现问题在那儿了 嘿嘿