2 Replies Latest reply on Jan 12, 2006 10:41 AM by anil.saldhana

    Defining multiple services in Tomcat server.xml

    anil.saldhana

      User forum reference:
      http://www.jboss.com/index.html?module=bb&op=viewtopic&t=71636

      Jira Issue:
      http://jira.jboss.com/jira/browse/JBAS-2410

      When Tomcat5 service starts, by default, catalinaDomain is defined as "Catalina", which gets overridden by the mbean injection of "SetDomain" to jboss.web. So that will provide me a bunch of mbeans under jboss.web domain.

      jboss.web
      # name=StandardEngineValve,type=Valve
      # name=channelSocket,type=JkHandler
      # name=http-0.0.0.0-8080,type=GlobalRequestProcessor
      # name=http-0.0.0.0-8080,type=ThreadPool
      # name=jk-8009,type=GlobalRequestProcessor
      # name=jk-8009,type=ThreadPool
      # name=request,type=JkHandler
      # service=WebServer
      # serviceName=jboss.web,type=Service
      # type=Engine
      # type=JkMain
      # type=JkWorkerEnv
      # type=Realm
      # type=server
      


      The domain name "jboss.web" has a direct relation to the service defined in tomcat server.xml called "jboss.web". Now if I want to define multiple services in server.xml, there is no problem. The services get started fine, except for the connectors(which is our intended behavior).

      The added services, example: my.web, test.web that are defined in server.xml will get the mbeans under the respective domain.
      my.web
       * address=/0.0.0.0,port=8081,type=Connector
       * host=myhost,name=ErrorReportValve,type=Valve
       * host=myhost,name=StandardHostValve,type=Valve
       * host=myhost,type=Deployer
       * host=myhost,type=Host
       * name=StandardEngineValve,type=Valve
       * serviceName=my.web,type=Service
       * type=Engine
       * type=Realm
      


      The issue is: how does one get hold of the tomcat services that are deployed?

      Approaches and problems:
      1) Ask the core catalina mbean under Catalina:type=Server, what your serviceNames are?
      This is the right approach but the problem is it throws a ClassCastException because we have our own version of StandardService called "org.jboss.web.tomcat.tc5.StandardService", which was introduced because we wanted to lazy start the connectors.
      2) Query the MBean server for mbeans of type "*:type=service" and this gives me maybe 4-5 mbeans and then I can filter out very easily to obtain the service names and from there I can start the connectors.
      3) Query the MBean server for mbeans of type "*:type=connector" and see if it has a "port" key to obtain the connectors. Then start it.

      Approaches 2 and 3 seem hackish and they are doable.

      Thoughts/comments/corrections?