Uploaded image for project: 'mod_cluster'
  1. mod_cluster
  2. MODCLUSTER-711

Using "connectorPort" property fails if multiple services are configured in Tomcat

    XMLWordPrintable

Details

    • Hide

      1. Add an additional service to Tomcat configuration:

        <Service name="TestService">
      
          <Connector port="8081" protocol="HTTP/1.1"
                     connectionTimeout="20000"
                     redirectPort="8443" />
      
      
          <Engine name="TestEngine" defaultHost="localhost">
      
      
            <Host name="localhost"  appBase="webapps"
                  unpackWARs="true" autoDeploy="true">
      
              <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
                     prefix="localhost_access_log" suffix=".txt"
                     pattern="%h %l %u %t &quot;%r&quot; %s %b" />
      
            </Host>
          </Engine>
        </Service>
      

      2. Configure the mod_cluster listener with connectorPort

        <Listener className="org.jboss.modcluster.container.catalina.standalone.ModClusterListener"
             connectorPort="8081"
             advertise="false"
             stickySession="true"
             stickySessionForce="false"
             stickySessionRemove="true"
             proxyList="localhost:6666"
             excludedContexts="manager" />
      
      Show
      1. Add an additional service to Tomcat configuration: <Service name= "TestService" > <Connector port= "8081" protocol= "HTTP/1.1" connectionTimeout= "20000" redirectPort= "8443" /> <Engine name= "TestEngine" defaultHost= "localhost" > <Host name= "localhost" appBase= "webapps" unpackWARs= " true " autoDeploy= " true " > <Valve className= "org.apache.catalina.valves.AccessLogValve" directory= "logs" prefix= "localhost_access_log" suffix= ".txt" pattern= "%h %l %u %t &quot;%r&quot; %s %b" /> </Host> </Engine> </Service> 2. Configure the mod_cluster listener with connectorPort <Listener className= "org.jboss.modcluster.container.catalina.standalone.ModClusterListener" connectorPort= "8081" advertise= " false " stickySession= " true " stickySessionForce= " false " stickySessionRemove= " true " proxyList= "localhost:6666" excludedContexts= "manager" />
    • Compatibility/Configuration

    Description

      If the Tomcat server configuration has several <service> elements and the mod_cluster listener is configured with connectorPort (most probably it is the same with connectorAddress), the configuration fails with these messages:

      06-Feb-2020 16:11:17.596 INFO [ContainerBackgroundProcessor[StandardEngine[TestEngine]]] org.jboss.modcluster.ModClusterService.connectionEstablished MODCLUSTER000012: TestEngine connector will use /127.0.0.1
      06-Feb-2020 16:11:17.598 INFO [ContainerBackgroundProcessor[StandardEngine[TestEngine]]] org.jboss.modcluster.ModClusterService.establishJvmRoute MODCLUSTER000011: TestEngine will use 7bb39e02-96c0-3f8f-9fab-d464ad729cfe as jvm-route
      06-Feb-2020 16:11:17.598 SEVERE [ContainerBackgroundProcessor[StandardEngine[TestEngine]]] org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren Exception invoking periodic operation: 
       java.lang.RuntimeException: MODCLUSTER000047: No configured connector matches specified host:port (*:8081)! Ensure connectorPort and/or connectorAddress are configured.
      	at org.jboss.modcluster.container.tomcat.ConfigurableProxyConnectorProvider.createProxyConnector(ConfigurableProxyConnectorProvider.java:89)
      	at org.jboss.modcluster.container.tomcat.TomcatEngine.getProxyConnector(TomcatEngine.java:140)
      	at org.jboss.modcluster.ModClusterService.connectionEstablished(ModClusterService.java:267)
      	at org.jboss.modcluster.mcmp.impl.DefaultMCMPHandler.status(DefaultMCMPHandler.java:341)
      	at org.jboss.modcluster.mcmp.impl.DefaultMCMPHandler.status(DefaultMCMPHandler.java:315)
      	at org.jboss.modcluster.ModClusterService.status(ModClusterService.java:388)
      	at org.jboss.modcluster.container.tomcat.TomcatEventHandlerAdapter.lifecycleEvent(TomcatEventHandlerAdapter.java:229)
      	at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
      	at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1174)
      	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1396)
      	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1368)
      	at java.lang.Thread.run(Thread.java:748)
      

      My own code inspection suggests this is because of this loop :

      org.jboss.modcluster.ModClusterService
          @Override
          public void connectionEstablished(InetAddress localAddress) {
              for (Engine engine : this.server.getEngines()) {
                  Connector connector = engine.getProxyConnector();
                  InetAddress address = connector.getAddress();
      
                  // Set connector address
                  if ((address == null) || address.isAnyLocalAddress()) {
                      connector.setAddress(localAddress);
      
                      ModClusterLogger.LOGGER.detectConnectorAddress(engine, localAddress);
                  }
      
                  this.establishJvmRoute(engine);
              }
      
              this.established = true;
          }
      

      The problem here is that the invocation of engine.getProxyConnector() will check if one and only one of the connectors in the engine matches the port configured by connectorPort. If more that one service is configured there will be multiple engines and this code will apply the previous condition to all of them. That is, to properly exit this method the port should exist in all engines, which will not happen normally.

      Attachments

        Activity

          People

            rhn-engineering-rhusar Radoslav Husar
            rhn-support-tbriceno Tomas Briceno Fernandez
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: