3 Replies Latest reply on Jan 12, 2006 2:49 PM by starksm64

    Defining multiple 'Service(s)' in Tomcat's server.xml

    daereth

      In Tomcat (standalone), I'm able to define multiple services each with their own connectors to different ports.

      For instance, something like this:

       <Service name="ABC">
       <Connector port="8081" maxHttpHeaderSize="8192"
       maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
       enableLookups="false" redirectPort="8443" acceptCount="100"
       connectionTimeout="20000" disableUploadTimeout="true" />
       <Engine name="ABC" defaultHost="myhost">
       <Host name="myhost" appBase="webapps_abc"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">
       </Host>
       </Engine>
       </Service>
      
       <Service name="XYZ">
       <Connector port="8082" maxHttpHeaderSize="8192"
       maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
       enableLookups="false" redirectPort="8443" acceptCount="100"
       connectionTimeout="20000" disableUploadTimeout="true" />
       <Engine name="XYZ" defaultHost="myhost2">
       <Host name="myhost2" appBase="webapps_xyz"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">
       </Host>
       </Engine>
       </Service>
      


      This allows different web apps to be served on different ports.

      I've tried setting up a similar configuration in the embbeded Tomcat on JBoss 4.0.2 and it "almost" works:

       <Service name="my.web"
       className="org.jboss.web.tomcat.tc5.StandardService">
       <Connector port="8081" address="${jboss.bind.address}"
       maxThreads="250" strategy="ms" maxHttpHeaderSize="8192"
       emptySessionPath="true"
       enableLookups="false" redirectPort="8443" acceptCount="100"
       connectionTimeout="20000" disableUploadTimeout="true"/>
       <Engine name="my.web" defaultHost="myhost">
       <Realm className="org.jboss.web.tomcat.security.JBossSecurityMgrRealm"
       certificatePrincipal="org.jboss.security.auth.certs.SubjectDNMapping"
       />
       <Host name="myhost" appBase="/full/path/to/app/base"
       autoDeploy="true" deployOnStartup="true" deployXML="true">
       </Host>
       </Engine>
       </Service>
      
      
       <Service name="jboss.web"
       className="org.jboss.web.tomcat.tc5.StandardService">
      
       <!-- A HTTP/1.1 Connector on port 8080 -->
       <Connector port="8080" address="${jboss.bind.address}"
       maxThreads="250" strategy="ms" maxHttpHeaderSize="8192"
       emptySessionPath="true"
       enableLookups="false" redirectPort="8443" acceptCount="100"
       connectionTimeout="20000" disableUploadTimeout="true"/>
      
       ...
       </Service>
      


      Changes from the original Tomcat server.xml config include:
      className attribute in the Service element
      appBase attribute in the Host element (where to load the wars. note: not in the standard deploy directory)
      autoDeploy, deployOnStartup and deployXML attributes set to true


      So when JBoss is started up, I can see that the Http11Protocol class has initialised the Coyote Connector on port 8081. The StandardService class is starting the my.web service. The web apps found in the directory "/full/path/to/app/base" have been deployed.

      All seems well. However, even though the connectors from the standard service set up has been started, the connector from the my.web service has not been started at all.

      Going through the jmx-console, you can actually see that the my.web service has been initialised. Everything will finally work if you MANUALLY start the connector (named address=/0.0.0.0,port=8081,type=Connector) through the JMX start() operation.

      So what am I missing? Why isn't the connector automatically started? Has anyone ever encountered this behavior or tried this type of configuration in JBoss?

      Any help would be appreciated!

      Mike