• Post Reply Bookmark Topic Watch Topic
  • New Topic

Port 8081 being used and I don't know why

 
Phil Moschovas
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

First post here and I'm hoping you can help me out with an issue I've inherited.  I've been reading some posts on here that have helped me out so far but I need to get over this last hump.

A little background first.  I inherited a legacy web application that was built-in house long before I got here.  While it's main function is a document repository, it also has some other functions that were added along the way.  As is probably the case in many places, you get something built quick and dirty, it's exactly what people need and it ends up sticking around forever and the people who originally built it are long gone.  It's running currently on Tomcat 4, Java 1.4 on an old Solaris server.  Due to a move to IE 11, we had a small project put together to do some updating to make it display properly and I am the one who now needs to do the deployment.  It was redesigned in Eclipse and tested there and on our UAT server with Tomcat 5.

The production server also has Tomcat 5 installed and that's where I deployed the .WAR file.  I stop Tomcat 4 for the currently deployed version and start up the new version of the application on Tomcat 5.

After a few attempts and some rework, I was able to finally get it to launch on Tomcat 5 and it works as it's supposed to for the most part.  I'm able to navigate and search for documents with no issue.  However, when I click on the document to open it, it returns a 404 not found error and I see it's due to it looking for the document on port 8081 instead of port 8080 where the rest of the site runs.  The strange thing is that I can find absolutely no record of a reference to port 8081 in any of the XML config files, nor in the .java or .jsp files.  I asked the server admins to Grep for 8081 and nothing is returned under the Tomcat 5 folder.  The only reference to 8081 exists in files that have been backed up in the Tomcat 4 folder and are not used at all.

Has anyone seen something like this before or any idea on where to look?

Many thanks in advance,
Phil

 
Ron McLeod
Bartender
Posts: 1181
100
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Was the old version running on port 8081, or was it maybe running two instances of Tomcat - one for the UI and one for the document server?

Since you haven't found a reference to port 8081 in the running code, could there be a reference to port 8081 in the document metadata?
 
Phil Moschovas
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ron McLeod wrote:Was the old version running on port 8081, or was it maybe running two instances of Tomcat - one for the UI and one for the document server?

Since you haven't found a reference to port 8081 in the running code, could there be a reference to port 8081 in the document metadata?


No.  The current version on Tomcat 4 uses 8080.  There is no document server, the documents are all stored on the file system of the server and the database stores the link it.

There was a version of the app in the Tomcat 5 folder that I removed before deploying my .WAR file.  As far as I know, Tomcat 5 was never used for this application.  I can only assume they wanted to and abandoned it along the way.

However, your reply did make me think of something.  I'm wondering if there is a reference to the port somewhere in the Database because that's the only place I haven't looked.

Thanks,
Phil
 
Tim Holloway
Saloon Keeper
Posts: 18387
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Phil!

I think port 8081 is favored for appliance servers such as what you're describing. It's not an official standard or anything, but I think it's popular for that. You can use the "netstat -lnp" command on Linux to find what process owns port 8081, though.

Tomcat 5 is just as dead ad Tomcat 4. The absolute oldest Tomcat you should port to if you don't want to see everything break again in short order is Tomcat 6. Currently, I think Tomcat 9 is in Beta and Tomcat 8 is in primary production.

To find the ports that Tomcat uses, look at its conf/server.xml file and search for "port=". Port 8080 is the default http port, port 8005 is the control port, port 8009 is the AJP proxy port and port 8443 is the SSL (https) port.
 
Phil Moschovas
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:Welcome to the JavaRanch, Phil!

I think port 8081 is favored for appliance servers such as what you're describing. It's not an official standard or anything, but I think it's popular for that. You can use the "netstat -lnp" command on Linux to find what process owns port 8081, though.

Tomcat 5 is just as dead ad Tomcat 4. The absolute oldest Tomcat you should port to if you don't want to see everything break again in short order is Tomcat 6. Currently, I think Tomcat 9 is in Beta and Tomcat 8 is in primary production.

To find the ports that Tomcat uses, look at its conf/server.xml file and search for "port=". Port 8080 is the default http port, port 8005 is the control port, port 8009 is the AJP proxy port and port 8443 is the SSL (https) port.


Thanks Tim!!!

I hear you on the danger of using such old versions.  We are looking to replace this application next year or early 2018 and are just trying to squeeze a little bit more life out of it.  It's so old, we're all afraid to touch it for fear it might die and never come back.  Every time I try to finish the deploy I get the cold sweats.

There is nothing in the server.xml file regarding 8081.  It's set up exactly with the ports you mentioned above.  I'll double check the file the sys admin gave me when he ran the grep command.  I think he also did the netstat one as well.
 
Tim Holloway
Saloon Keeper
Posts: 18387
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One other possibility might be that a proxy server (IIS, Apache, Nginx etc.) could be the one actually listening on port 8081 and forwarding to Tomcat. Or, on systems using a system like Linux iptables, port forwarding might happen at the device level.
 
Phil Moschovas
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:One other possibility might be that a proxy server (IIS, Apache, Nginx etc.) could be the one actually listening on port 8081 and forwarding to Tomcat. Or, on systems using a system like Linux iptables, port forwarding might happen at the device level.


Hi Tim,

Finally had a chance to take a look into this again today.  I think you may be on to something because I see 2 virtual hosts in the httpd.conf file in the apache folder.  One of them does reference 8081.  Would commenting that out and restarting apache do the trick?

I'm still trying to figure out how the actual application is using 8081 for only the linking to the document though.

Thanks,
Phil
 
Tim Holloway
Saloon Keeper
Posts: 18387
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It could be.

There are 2 ways to reference port 8081 in Apache. If your config file is set to Listen on 8081, you've found the likely culprit (a netstat -lnp on Linux should show "apache2" or "httpd" as the port owner).

If your config file is using mod_proxy, though, then that's just set for Apache to send TO port 8081, and it's serving as a frontend for Tomcat.
 
Phil Moschovas
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:It could be.

There are 2 ways to reference port 8081 in Apache. If your config file is set to Listen on 8081, you've found the likely culprit (a netstat -lnp on Linux should show "apache2" or "httpd" as the port owner).

If your config file is using mod_proxy, though, then that's just set for Apache to send TO port 8081, and it's serving as a frontend for Tomcat.


Hmmmm...looks like -l is not a valid attribute on this version of Solaris.  This is what will work.

netstat: illegal option -- l
usage: netstat [-anv] [-f address_family]
       netstat [-g | -p | -s] [-n] [-f address_family] [-P protocol]
       netstat -m
       netstat -i [-I interface] [-an] [-f address_family] [interval]
       netstat -r [-anv] [-f address_family|filter]
       netstat -M [-ns] [-f address_family]
       netstat -D [-I interface] [-f address_family]

I did a netstat -an and got the following.
TCP: IPv6
   Local Address                     Remote Address                 Swind Send-Q Rwind Recv-Q   State      If
--------------------------------- --------------------------------- ----- ------ ----- ------ ----------- -----
      *.*                               *.*                             0      0 49152      0 IDLE            
      *.7100                            *.*                             0      0 49152      0 LISTEN          
      *.6112                            *.*                             0      0 49152      0 LISTEN          
      *.515                             *.*                             0      0 49152      0 LISTEN          
      *.514                             *.*                             0      0 49152      0 LISTEN          
      *.513                             *.*                             0      0 49152      0 LISTEN          
      *.512                             *.*                             0      0 49152      0 LISTEN          
      *.665                             *.*                             0      0 49152      0 LISTEN          
      *.23                              *.*                             0      0 49152      0 LISTEN          
      *.25                              *.*                             0      0 49152      0 LISTEN          
      *.22                              *.*                             0      0 49152      0 LISTEN          
      *.8080                            *.*                             0      0 49152      0 LISTEN          
      *.8081                            *.*                             0      0 49152      0 LISTEN    

Looks like it just confirms what the config file says that it is listening on 8081 however, doesn't say if it's apache.  I don't see what else it could be.

 
Tim Holloway
Saloon Keeper
Posts: 18387
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your're running MS Windows, aren't you?

I don't think the Windows version of netstart can tell you what process owns a port. But if you look around, you may be able to find a program that does. There's a third-party program that I used to use that would tell me a lot about Windows processes, although I don't know if network ports were reported by it or not. The last time I touched a Windows system was when I did my income taxes last April and I wouldn't have done so then if Intuit supported Linux.
 
Ron McLeod
Bartender
Posts: 1181
100
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:I don't think the Windows version of netstart can tell you what process owns a port.

With Windows its the -b option for netstat.

Phil has a Solaris platform - I don't think there is a netstat option to show the pid in Solaris.
 
Tim Holloway
Saloon Keeper
Posts: 18387
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ron McLeod wrote:
Tim Holloway wrote:I don't think the Windows version of netstart can tell you what process owns a port.

With Windows its the -b option for netstat.

Phil has a Solaris platform - I don't think there is a netstat option to show the pid in Solaris.


OK. I think lsof might be available. I make no guarantees, since Solaris often lacks some of the amenities of Linux, but chances are fairly good that lsof is available and that it will show pids. More than that I cannot say without digging out the old manuals.
 
Phil Moschovas
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's frustrating not being able to dedicate my full time to this.  I keep having to jump between priorities.  Anyways, here's what I've discovered today.

It seems like I was mistaken on one point I made originally.  I had thought that port 8081 was only listening when Tomcat 5 was started. This is not the case.  Even with Tomcat 5 down and Tomcat 4 running, the same PDFs are available using either port.  For whatever reason, I hadn't thought to try it before now.

I ran lsof and I noticed this.

httpd      3373   webguy    4u  IPv6 0x300160893d8         0t0       TCP *:8080 (LISTEN)
httpd      3373   webguy    5u  IPv6 0x30016089558         0t0       TCP *:8081 (LISTEN)


I'm guessing that the reason it works is because the apache config has a listener defined on both ports.  However, when I look at the way the application is built, the port and server name is loaded at run time as an environment variable that is defined in server.xml.  Nowhere does it reference 8081 though so I'm not sure how the application knows to load it.


 
Tim Holloway
Saloon Keeper
Posts: 18387
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that the lsof command has a "-p" option that can list the port's owning processid and narrow it down to whichever program actually has that port.

You configure Apache to listen on a port using the Listen directive in its config file (which on most systems these days is a main file and included fragments). You then can define a VirtualHost for that port/IP combination (default would be on the main host).

You configure Tomcat to listen on a port using a Connector directive in the Tomcat server.xml file.

There is no other way to get either of these programs to open or listen on a port unless you manually jam in specialized network logic - which is very unlikely for your situation.

Usually when Apache is operating as a proxy (technically, it's a reverse proxy), you would define the VirtualHost to employ either mod_proxy or mod_jk. In mod_proxy, you indicate the URL - including hostname and target port as a configuration option. For a vanilla Tomcat, that would be whatever server the Tomcat server was on (could be localhost, could be another machine or VM or container) and port 8080 (as defined in its server.xml) For mod_jk, you'd define workers, which would reference hosts and the jk port (usually that's 8009 and again, it's configured in the target Tomcat server.xml)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!