31

According to the instructions in some blogs I tried to modify the C:\Program Files\Apache Software Foundation\Tomcat 7.0\conf\tomcat-users.xml file as

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<!--
  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <user username="tomcat" password="tomcat" roles="tomcat"/>
  <user username="both" password="tomcat" roles="tomcat,role1"/>
  <user username="role1" password="tomcat" roles="role1"/>
-->
  <role rolename="manager"/>
  <role rolename="admin"/>
  <user username="admin" password="admin" roles="admin,manager"/>
</tomcat-users>

But Save Failed dialog box is appearing with the text " Please check if this file is opened in another program". But I am sure that none of the programs are started/running related to this file. The modification permission is denied. what is the reason..?

kapex
  • 28,903
  • 6
  • 107
  • 121
Sajeev
  • 401
  • 1
  • 4
  • 15
  • Maybe some windows uac permission problem, text editors usually give this error if you try modify system files. Not sure if it helps, but with system files it works like this: If you copy the file somewhere to your user directory, edit the copy and replace the original file with it, you get a confirmation dialog and can replace it. – kapex Jan 05 '13 at 15:16

3 Answers3

62

I think the reason is that you can't edit files in "Program Files" without administrator rights.

I had that kind of problem several times and I usually solve it by running my text editor with admin rights.

For example, to edit file with notepad in Windows 7: Find it in your start menu, click on it with right mouse button. You should be able to choose "run as administrator" from the context menu. Now edit the file and you should be able to save it.

Paweł Chorążyk
  • 3,584
  • 3
  • 27
  • 33
0

I believe, in my case the issue was that Tomcat Server was also running in Eclipse. So, I stopped the Tomcat Server from Eclipse and I had no problem editing and saving the tomcat-users file. I added username as admin and password as admin and the role from the instructions in the error message - saved the file and I was able to login from the Tomcat web page.

Jim Mehta
  • 56
  • 2
  • 8
-1

It might be helpful to note, please explicitly mention all the roles in tomcat-users.xml. Please see below:

<role rolename="manager-gui"/>    
<role rolename="manager-script"/>    
<role rolename="manager-jmx"/>    
<role rolename="manager-status"/>    
<role rolename="admin"/>    
<user username="admin" password="admin" roles="admin,manager-gui,
manager-script,manager-jmx,manager-status"/>
ksokol
  • 8,035
  • 3
  • 43
  • 56
Suvro Choudhury
  • 115
  • 1
  • 5
  • 18