tomcatstartupmanager-app

tomcat deploy only manager on startup


i have a little strange problem. The security department in my company wants every tomcat to respect the following configuration parameters:

autoDeploy="false"
deployOnStartup="false"

When i configure the above parameters no web app (including the manager-app) will be deployed on startup and i can't deploy apps through the manager-app...

Can i define the deployment of the manager-app in server.xml or something like this? I want only to deploy the manager-app on startup.

Edit: Here is my ${CATALINA_HOME}/conf/server.xml

...
<Service name="Catalina">
...

<Engine name="Catalina" defaultHost="localhost">
...
<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="false"
            deployOnStartup="false"
            xmlValidation="false" xmlNamespaceAware="false"
            deployXml="false">
...

and this is my ${CATALINA_HOME}/webapps/manager/META-INF/context.xml

<Context path="/manager"
        docBase="/usr/share/tomcat6/webapps/manager"
        debug="0"
        privileged="true"
        autoDeploy="true"
        deployOnStartup="true">

    <ResourceLink name="users"
                global="UserDatabase"
                type="org.apache.catalina.UserDatabase"/>

    <Valve className="org.apache.catalina.valves.RemoteAddrValve"
                allow="127.0.0.1"/>

</Context>

greets

Goetz


Solution

  • From the Apache 6 documentation: https://tomcat.apache.org/tomcat-6.0-doc/config/context.html in the Attributes section of Context, the documentation for the path attribute specifies:

    This attribute must only be used when statically defining a Context in server.xml. In all other circumstances, the path will be inferred from the filenames used for either the .xml context file or the docBase.

    Even when statically defining a Context in server.xml, this attribute must not be set unless either the docBase is not located under the Host's appBase or both deployOnStartup and autoDeploy are false. If this rule is not followed, double deployment is likely to result.

    The same documentation exists in Tomcat 7, so I tried the following on Tomcat 7 and I managed to deploy only the manager application.

    <Host appBase="webapps"  autoDeploy="false"  deployOnStartup="false" name="localhost" unpackWARs="true">
            <Context docBase="manager" 
                   path="/manager"  
                   antiResourceLocking="false" privileged="true" 
                   />
    </Host>
    

    Basically, what I did was to copy the contents of the webapps/manager/META-INF/context.xml and paste them inside the <Host> element of server.xml, ensuring of course that the path and docBase attributes were also present, as the documentation specifies. In your case I believe it would be:

    <Host name="localhost"  appBase="webapps"
                unpackWARs="true" autoDeploy="false"
                deployOnStartup="false"
                xmlValidation="false" xmlNamespaceAware="false"
                deployXml="false">
    
    <Context path="/manager"
            docBase="/usr/share/tomcat6/webapps/manager"
            debug="0"
            privileged="true">
    
        <ResourceLink name="users"
                    global="UserDatabase"
                    type="org.apache.catalina.UserDatabase"/>
    
        <Valve className="org.apache.catalina.valves.RemoteAddrValve"
                    allow="127.0.0.1"/>
    
    </Context>
    
    </Host>