Saturday, April 5, 2008

Create a manager accout

It is very usefull to create a manager account in your tomcat. In fact it will be used to access all the administration sections that you can see if you point to the root of your tomcat from a browser (e.g. http://localhost:8080/). But it is also usefull if you want to start, stop, redeploy... from the url with the tomcat manager (http://{host}:{port}/manager/{command}?{parameters}) or with ant. We have to open tomcat-users.xml (..apache-tomcat-5.5.26\conf\tomcat-users.xml). We will add the following lines:

<role rolename="manager">
...
<user username="user" password="pass" roles="manager">

So in the end we will have something like this:

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

Use tomcat through a proxy

During last days I had the necessity to access from my development tomcat the external world (e.g. access remote web services). The problem is that, inside my network, access to the external world is achieved through a proxy with autentication. The solution is to add the following line to your catalina.properties (..\apache-tomcat-5.5.26\conf\catalina.properties):

http.proxyHost=my.proxy.com
http.proxyPort=8080
http.proxyUser=user
http.proxyPassword=password

VoilĂ !