Friday, August 23, 2013

Multiple applications listening on One Port

I've had the most ridiculous time with Apache Tomcat on a windows machine for the past 2 days that became so easy to fix I really could throw a shoe at myself.

The Setup

I was running Tomcat on port 8080, and also have a VirtualBox machine that is performing port forwarding of 8080 to a Glassfish running on a virtual machine. I didn't realise it until much much later though....

The Weirdness

The Glassfish server is running an application and is accessed via a domain name (pxmsvcjfb.... for me). Thats because its an opensso server and has to have a domain name. And from a browser it works no problems.
And from a browser I can also go to http://localhost:8080/ and the Tomcat application shows, and if I use http://pxmsvcjfb/opensso no problem.

The Restful Web services can also be called from the browser against http://localhost:8080/. However : if I try to call the web services through java client (Jersey WebResource), I only ever get a 404 not found. Yet had another webapp on port 7080 and that worked just fine. I was starting to think it was the Jersey client doing something strange.

Checking a netstat -an gave this :

 TCP    0.0.0.0:8080           bushlaptop:0           LISTENING
 TCP    0.0.0.0:8080           bushlaptop:0           LISTENING


Eek there are 2 processes listening on port 8080!

The solution

I changed the Tomcat port to 9080 and miraculously everything started to work!

No comments: