Tuesday, March 13, 2018

What Happened to My Alfresco Simple Modules?

Alfresco supports two methods for packaging Repository and Share extensions:

  • Alfresco Module Package (AMP)
  • Simple Module

The Simple Module method makes use of JAR files and has the advantage of not having to modify the alfresco.war and share.war files as is required by the AMP method.

The Formtek Extensions for Alfresco (Auditing, File Linking, Peer Association, and Version Browser) are all installed as Simple Modules and each contain Repository and Share extensions. The Repository extensions are bundled in a JAR file that is placed in the modules/platform directory, where as the JAR file with the Share extensions is placed in the modules/share directory.

When Alfresco starts up, it checks for JAR files in these two directories to see if there are any modules to load. If a module is found, it is loaded and subjected to any required checks, such as its dependent Platform and Share versions. If it passes these checks, the module is started.

So far, so good. Well, most of the time. On multiple occasions when I restarted my Alfresco installation, my Simple Modules failed to load even though they had not changed since the last successful startup. For me, it seemed the Repository extensions were not being found. It is was as if the Alfresco startup process wasn't even looking in the modules/platform directory anymore. The first time this happened I figured I had done something wrong and messed up my Alfresco installation. But when it happened a third and fourth time, I began my investigation.

I figured some Tomcat-related file in my installation is telling (or should be telling) Alfresco to look in the modules/platform directory on startup for JAR files to load. I eventually landed in the tomcat/conf/Catalina/localhost directory and discovered it only contained two files: share.xml and solr4.xml. When I compared this to another installation I had that was working fine, I found that I was missing the alfresco.xml file.

Indeed, it is the alfresco.xml and share.xml files that tell Alfresco where to look for Simple Modules as follows:

alfresco.xml
<?xml version='1.0' encoding='utf-8'?>
<Context crossContext="true">
  <Loader className="org.apache.catalina.loader.VirtualWebappLoader" virtualClasspath="${catalina.base}/../modules/platform/*.jar" />
</Context>

share.xml
<?xml version='1.0' encoding='utf-8'?>
<Context crossContext="true">
  <Loader className="org.apache.catalina.loader.VirtualWebappLoader" virtualClasspath="${catalina.base}/../modules/share/*.jar" />
</Context>

Once I recreated the missing alfresco.xml file and restarted Alfresco, my Simple Module Repository extensions loaded and started just fine. What I have yet to determine, however, is why the file was missing in the first place? But, at least I now know how to fix it should it reoccur.

NOTE: If you've deviated from the traditional Alfresco installation and placed your modules directory elsewhere, it is worth noting that you will need to edit the virtualClasspath location in these two files to match your installation.

No comments:

Post a Comment