17

I am new to Java/Tomcat development and I am seeing this issue where my tomcat-users.xml file keeps getting reset. My user keeps getting removed and I'm not sure why. I am launching my application from Eclipse that is being deployed to this Tomcat instance.

C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0

VM Arguments

-Dcatalina.base="C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0" -Dcatalina.home="C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0" -Dwtp.deploy="C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\wtpwebapps" -Djava.endorsed.dirs="C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\endorsed"
Mike Flynn
  • 22,342
  • 54
  • 182
  • 341
  • When you launch from Eclipse, doesn't eclipse have a built in Tomcat engine it uses? I.e., could you have your environment configured such that your local tomcat directory gets overwritten by Eclipse's built-in Tomcat every time you launch? – Marc Mar 06 '13 at 18:21
  • I dont know, like I said I would be ignorant to answer that question. – Mike Flynn Mar 06 '13 at 18:22
  • Possible duplicate of [Tomcat 7 overrides the tomcat-users.xml when using Eclipse](http://stackoverflow.com/questions/16517659/tomcat-7-overrides-the-tomcat-users-xml-when-using-eclipse) – Steve Chambers Nov 05 '15 at 10:17

3 Answers3

31

I updated the tomcat-users.xml file under Servers in Project Explorer. That seems to be copying it over to the real Tomcat Server.

Mike Flynn
  • 22,342
  • 54
  • 182
  • 341
  • 1
    You could also just deploy to a different directory than your "real" tomcat, which would prevent having to track down this strangeness down the road if you start using your real tomcat. But either way, sounds like you got it fixed. – Marc Mar 06 '13 at 18:47
3

Please try this :

  • Go to tomcat's conf folder and open the server.xml file, in the file between 'GlobalNamingResources' tags you will get 'Resource' tag , add readonly="true" and thats all you need.
Soumyaansh
  • 8,626
  • 7
  • 45
  • 45
2

If using any IDE, Update server.xml in Eclipse as below:

<Resource auth="Container" readonly="true" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
Prasad Khode
  • 6,602
  • 11
  • 44
  • 59