Start two or more Tomcat instances on localhost machine


Octocat Save up to a workweek a year by efficiently managing your coding bookmarks, aka #codingmarks, on www.codingmarks.org. Share your favorites with the community and they will be published weekly on Github. Help us build the programming-resources location - Star


There are to main applications, that power Podcastpedia.org, one that is actually the web application and another one where I do administrative stuff and podcast updates. Experience has shown that if I want to run the podcasts updates in the background and do some testing/debugging/redployment on the front-end application it’s better to have them running on different Tomcat instances on the development machine.

How do I do that? It’s very easy. First make a copy of one instance and name it as you please:

Clone Tomcat directory

Clone Tomcat directory

After that go to the conf/server.xml file and modify the ports from the Connector entries:

original

.......
<Connector port="8080" protocol="HTTP/1.1"
		   connectionTimeout="20000"
		   redirectPort="8443" />
......
<!-- Define an AJP 1.3 Connector on port 8010 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
....

modified

.......
<Connector port="8081" protocol="HTTP/1.1"
		   connectionTimeout="20000"
		   redirectPort="8444" />
......
<!-- Define an AJP 1.3 Connector on port 8010 -->
<Connector port="8010" protocol="AJP/1.3" redirectPort="8444" />
....

And then start your two instances. Because I still get an java.net.BindException: Address already in use: JVM_Bind error:

27.11.2013 06:56:47 org.apache.catalina.core.StandardServer await
SEVERE: StandardServer.await: create[localhost:8005]:
java.net.BindException: Address already in use: JVM_Bind
	at java.net.PlainSocketImpl.socketBind(Native Method)
	at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383)
	at java.net.ServerSocket.bind(ServerSocket.java:328)
	at java.net.ServerSocket.<init>(ServerSocket.java:194)
	at org.apache.catalina.core.StandardServer.await(StandardServer.java:427)
	at org.apache.catalina.startup.Catalina.await(Catalina.java:779)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:725)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:456)

it means I have forgot to change the port number from the Server entry:

default

<Server port="8005" shutdown="SHUTDOWN">

modified

<Server port="8006" shutdown="SHUTDOWN">

That’s it. You should now be able to run the two instances of Tomcat 7 with no trouble. If you want to start a third one and so one, follow the same procedure and use different port numbers.

Don’t forget to check out Podcastpedia.org – you might find it really interesting. We are grateful for your support.

Podcastpedia image

Adrian Matei

Creator of Podcastpedia.org and Codingpedia.org, computer science engineer, husband, father, curious and passionate about science, computers, software, education, economics, social equity, philosophy - but these are just outside labels and not that important, deep inside we are all just consciousness, right?

How I save a workweek a year by efficiently managing my codingmarks

Finding a desired link, you already visited, can be a tedious job and sometimes even frustrating. It normally takes 30 seconds or more to look for a link the traditional way, and I do that at least 20 times a day. With codingmarks.org it takes about 10 seconds, so I get a time saving of around 20 * 20 / 60 = 6.66 minutes a day. Over a year's time this translates to around 40+ hours of saved time. Continue reading

New codingmarks published in week 52 of 2018

Published on January 01, 2019