Skip to content

Instantly share code, notes, and snippets.

@aitseitz
Last active September 29, 2023 16:23
Show Gist options
  • Save aitseitz/c80a742876fa63914f98daa267ae163a to your computer and use it in GitHub Desktop.
Save aitseitz/c80a742876fa63914f98daa267ae163a to your computer and use it in GitHub Desktop.
Alfresco Deployment Descriptor for Tomcat 9
<?xml version='1.0' encoding='utf-8'?>
<Context crossContext="true" docBase="{{ acs_home }}/ecm_war_delivery/alfresco.war">
<Resources cacheMaxSize="{{ tomcat_resource_cache }}" cacheObjectMaxSize="1024">
<PostResources base="${catalina.base}/../modules/platform"
className="org.apache.catalina.webresources.DirResourceSet"
webAppMount="/WEB-INF/lib"/>
</Resources>
</Context>
@aitseitz
Copy link
Author

Alfresco Deployment Descriptor

In the Tomcat 9.0 Documentation
https://tomcat.apache.org/tomcat-9.0-doc/config/context.html
is written:

Context Description
docbase The Document Base (also known as the Context Root) directory for this web application, or the pathname to the web application archive file (if this web application is being executed directly from the WAR file). You may specify an absolute pathname for this directory or WAR file, or a pathname that is relative to the appBase directory of the owning Host.The value of this field must not be set unless the Context element is defined in server.xml or the docBase is not located under the Host's appBase.If a symbolic link is used for docBase then changes to the symbolic link will only be effective after a Tomcat restart or by undeploying and redeploying the context. A context reload is not sufficient.
path The context path of this web application, which is matched against the beginning of each request URI to select the appropriate web application for processing. All of the context paths within a particular Host must be unique. If you specify a context path of an empty string (""), you are defining the default web application for this Host, which will process all requests not assigned to other Contexts.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.

In Tomcat 7 and Tomcat 8 I've used the following Deployment Descriptor in
/tomcat/conf/Catalina/localhost/alfresco.xml

<?xml version="1.0" encoding="UTF-8"?>
<Context crossContext="true" path="/alfresco" docBase="/home/alfresco01/content-services/ecm_war_delivery/alfresco.war">
    <Resources cachingAllowed="true" cacheMaxSize="153600">
        <PostResources base="${catalina.base}/../modules/platform"
            className="org.apache.catalina.webresources.DirResourceSet"
            webAppMount="/WEB-INF/lib" />
    </Resources>
</Context>
~          

After booting up ACS 7.2.1 I realized that Tomcat 9 throws a warn message if you use the deployment descriptors like this

2022-09-15T11:04:38,614 WARN  [main] [catalina.startup.HostConfig] The path attribute with value [/alfresco] in deployment descriptor [/home/alfresco01/content-services/tomcat/conf/Catalina/localhost/alfresco.xml] has been ignored

The reason is:
https://github.com/apache/tomcat/blob/9.0.x/java/org/apache/catalina/startup/HostConfig.java#L643

            if (context.getPath() != null) {
                log.warn(sm.getString("hostConfig.deployDescriptor.path", context.getPath(),
                        contextXml.getAbsolutePath()));
            } 

Prior to Tomcat 9 this message was not thrown...

Solution

You get rid of the WARN message above by simply remove path="" from deployment descriptor xml in case docbase="" is set.

<?xml version='1.0' encoding='utf-8'?>
<Context crossContext="true" docBase="/home/alfresco01/content-services/ecm_war_delivery/alfresco.war">
  <Resources cacheMaxSize="204800" cacheObjectMaxSize="1024">
    <PostResources base="${catalina.base}/modules/platform"
                   className="org.apache.catalina.webresources.DirResourceSet"
                   webAppMount="/WEB-INF/lib"/>
  </Resources>
</Context>         

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment