Tuesday, April 13, 2010

Setting admin password for fresh Tomcat installation

When tomcat server is installed for the first time in your local machine, and you point to : http://localhost:8080, and try to access admin console, you will be presented with the admin userID/password. However, you have no idea what the userID/password is!!.

Tomcat does not come with an admin userID/password. Instead, we are going to create one.

First, go to “<Tomcat Installation Directory>\conf” folder. Here, you will see a file named “tomcat-users.xml”. Open this file in your XML editor, or notepad. Change the file to look like the following:

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

 

Make sure you change the admin passwords to something more secure. I just used “adminpassword” as the password here for ease of understanding.

That’s it!!. Restart the Tomcat server, and you should now be able to log in as admin.