Wednesday, 25 July 2012

Running multiple instances of Tomcat on different ports on same server

I wanted to run two instances of Tomcat on different ports on my
workstation, and this is what I did.

Modify these values in /[TOMCAT INSTALL DIRECTORY]/conf/server.xml.

In this example we are using "7" to replace the "8" in the port numbers

ie, 2nd tomcat to run on port 7070 instead of 8080, shutdown port is
7005, AJP connector port is 7009

<!-- DEFAULT VALUE: 8005 -->
<Server port="7005" shutdown="SHUTDOWN">

<!-- DEFAULT VALUE: 8080 -->
<Connector port="7070" protocol="HTTP/1.1"
redirectPort="8443" URIEncoding="UTF-8" />

<!-- Define an AJP 1.3 Connector on port 8009 -->
<!-- DEFAULT VALUE: 8009 -->
<Connector port="7009" protocol="AJP/1.3" redirectPort="8443"
URIEncoding="UTF-8" />

Thursday, 5 July 2012

Adventures in legacy code: given a Map-based class, what do you think a method called getKey() should do?

Looking at some legacy code for a system that we're taking back from a
vendor. (Company has all these projects in-housing systems that used
to be outsourced) Rehost, port or rewrite?

Okay, so they created a class BundleMap that extends HashMap, and the
genius who wrote it added this incredible WTF "improvement":

* Check if the key is present in the resource bundle
* @param key
* @return true if key is present
public Boolean getKey(Object key) {
logger.debug("Returning value for key [" + key + "]");
if (super.containsKey(key)) {
return true;
return false;


you already have a perfectly good method called containsKey() in
HashMap -- whatever the hell possessed you to rename it as getKey()??