Bug 52028 - Embeded Tomcat using a Connector with a random port (port 0)
Embeded Tomcat using a Connector with a random port (port 0)
Product: Tomcat 7
Classification: Unclassified
Component: Connectors
All All
: P2 enhancement (vote)
: ---
Assigned To: Tomcat Developers Mailing List
Depends on:
  Show dependency tree
Reported: 2011-10-14 12:27 UTC by olamy
Modified: 2016-01-07 14:29 UTC (History)
0 users

v1 patch for discussion (8.41 KB, patch)
2011-10-28 17:52 UTC, Mark Thomas
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description olamy 2011-10-14 12:27:22 UTC
New feature based on discussion: http://markmail.org/message/3nczqiqm6smez255
Comment 1 Mark Thomas 2011-10-28 17:52:55 UTC
Created attachment 27861 [details]
v1 patch for discussion

I have started to look at this and it looks doable. port=0 works for all connectors for 64-bit Windows.

The problem is with MBean names, JMX MBean registration and logging info.

The port number is not available at the point where the JMX registration occurs. If bindOnInit="false", the port number may change multiple times during the life of the connector.

With multiple connectors using port="0" there will be a naming clash as the connectors need to be registered before the the ports are known.

I see two options.

1. Use auto-1, auto-2 instead of the port number in the JMX names (with a static, thread-safe counter).

2. Re-register the connector and related components when the port number changes.

I'm leaning towards one as it is a heck of a lot simpler.

Comment 2 Mark Thomas 2011-11-28 23:20:32 UTC
This has been fixed in trunk and back-ported to 7.0.x. It will be included in 7.0.24 onwards.
Comment 3 Konstantin Kolinko 2016-01-07 14:29:22 UTC
Backported to Tomcat 6 (r1723545, r1723551) and will be in 6.0.45 onwards.