AnsweredAssumed Answered

How to customize FreeMarker template by using Jar?

Question asked by Aleksey Bykov on Dec 1, 2017
Latest reply on Dec 1, 2017 by Aleksey Bykov

Some times ago, I used Alfresco 5.2 Community Edition. When I needed to develop some kind of customization, I used the Alfresco Maven SDK with three different Maven archetypes, it was:


  1. Alfresco Repository AMP;
  2. Alfresco Share AMP;
  3. Alfresco all-in-one (AIO).


By using this SDK I developed AMP files that overlaid on either the alfresco.war or share.war by using the module management tool.


Now I am using Alfresco 4.2.2 Enterprise Edition and the problem is that all the customizations over the years have been performed directly on the servers in the exploded WAR's.


This approach is described here: Packaging Approaches


Unpackaged Files or ZIP


Many development environments employ a build process that can execute a script to move unpackaged modified files from source control into the web application's exploded WAR file. Ant, bash, or some scripting language can all be good ways to do this ...

Moving unpackaged files has the advantage of being quick and easy to understand ...

And further:

Deployment Locations


One solution is to use a permanently exploded deployment (instead of deploying an Alfresco WAR file under /webapps). Create a directory called alfresco under the webapps directory and extract the contents of alfresco.war into it. Then copy your files to ../webapps/alfresco/WEB-INF/ and restart Tomcat ...


Thus, I can't use AMP-customizations(otherwise all previous developments will be deleted). As far as I know, I can use an alternative- JAR-customization.


As described here: Packaging And Deploying Extensions




As of v3.4, the Share web application supports overrides that are packaged as JAR files. This allows multiple customizations to be isolated from each other, and order of selection can be predicted. Static files such as JavaScript, CSS, or image files that would normally be placed in the web root of the Share application can also be packaged into these JARs ...


While it's possible to avoid the overwriting problem (at least in Tomcat) by placing these JAR files in tomcat/shared/lib ...


However, I can not take advantage of this approach either. For example, I need to override the FreeMarker template:




I create the appropriate directory structure in IDE, change the template in some way, and build the Jar file. Then I put it in tomcat7/shared/lib (I also placed it in tomcat7/webapps/share/WEB-INF/lib, but also without success) and restart the application server.


After restarting, I don't see my changes - the template remained the same. Moreover, if I try to add another template to the same directory (.../service-note/...), a new template there does not appear.


In my Tomcat installation shared classloader is configured properly.


What am I doing wrong? How to override static resources by using JAR?


I would be very grateful for the information. Thanks to all.