I am using Tomcat 7
to deploy my web projects on. Also I am more comfortable when using the Eclipse interface
to start and stop my Tomcat, so I've added it in the Eclipse's Servers
and check the "Use Tomcat Installation" in Server Locations
. One more thing that I use is the Tomcat's web Manager tool
to deploy/undeploy the projects.
As we know in order to use the Manager/html tool you have to sign in. The username and the password to authenticate are set in the tomcat-users.xml like this (in my file):
<role rolename="tomcat"/>
<role rolename="manager"/>
<role rolename="manager-script"/>
<role rolename="manager-gui"/>
<role rolename="standard"/>
<role rolename="admin"/>
<user username="tomcat-eclipse" password="tomcat-eclipse" roles="tomcat,manager,manager-script,standard,admin"/>
<user username="root" password="toor" roles="manager-gui" />
Everything works fine until some moment in time (I'm not sure but maybe after several restarts or redeploys) the configuration that I've entered is flushed and the default (empty configuration) file overrides my customized config.
Q: What causes the file to be overridden and how can I prevent that? Thanks.
Edit:
A: What I suggest based on some experiments is:
- Variant one: Change the Tomcat 7's tomcat-users.xml file before you add it to Eclipse. This is because I suspect when I was using the "Use Tomcat Installation" option Eclipse copied the old tomcat-users.xml in its metadata folder and when I change it later in Tomcat's install dir, it don't overrides it in the metadata. Then, for some reason, when running the server through Eclipse I suspect that it checks if the files are the same and if not then it overrides the tomcat-users.xml in the Tomcat's installation folder.
- Use "Use workspace metadata" option. It is default. Then go to the Eclipse's Package explorer -> Your Tomcat Server -> tomcat-users.xml and change it from there. You can also copy the contents of
your-tomcat-install-dir/webapps
intoyour-eclipse-workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/
in order to have the nice Tomcat html interface (as shown in Tutorial: Installing Tomcat 7 and Using it with Eclipse).
Try it. :)