Java Tomcat 7 Manager 无法登录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18746195/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Tomcat 7 Manager can't login
提问by Sergey Scopin
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?
有什么建议?
采纳答案by jlinxwiler
Remove the spaces between the roles for admin/admin. The list should just be comma separated as so:
删除 admin/admin 角色之间的空格。该列表应该只是以逗号分隔,如下所示:
<?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>
回答by Christoph G?ttert
I had the same issue but for me the reason was the server.xmlfile.
我有同样的问题,但对我来说原因是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 pathnameis set correctly to the location of your tomcat-users.xmlfile.
您必须确保将路径名正确设置为您的tomcat-users.xml文件的位置。
回答by jgrosch
Check the permissions and ownership on the file '/etc/tomcat7/tomcat-users.xml'. It should owned by root and group ownership should be tomcat7.
检查文件“/etc/tomcat7/tomcat-users.xml”的权限和所有权。它应该由 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 上
回答by gnarbarian
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. and then restarting tomcat.
对我有用的是从 tomcat-users.xml 文件中删除角色定义。然后重启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”
回答by victorio
And also check if it is not commented with:
还要检查它是否没有注释:
<!-- ... -->
回答by user55926
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.xml
或进行更改后重新启动 Tomcat server.xml
,context.xml
否则web.xml
更改才会生效。
In my case, the problem was I did not restart Tomcat after making changes.
Also on Tomcat 7 I had assigned manager-script
, manager-gui
roles to the same user. So Tomcat gave 403 error to enforce CRSF protection.
就我而言,问题是我在进行更改后没有重新启动 Tomcat。同样在 Tomcat 7 上,我已将manager-script
,manager-gui
角色分配给同一用户。所以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" />
回答by user7504161
Try
尝试
sudo apt-get install tomcat7-admin
回答by Vladimir Kravchenko
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 actualtomcat-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. Open tomcat-users.xml file and add some rows:
用于添加 gui-manager 用户/密码对的实际tomcat-users.xml 文件位于 C:\Users\\AppData\Roaming\NetBeans\8.2\apache-tomcat-8.0.27.0_base\conf\ 路径。打开 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 并再次尝试访问管理器。