Newly Deployed Sightly code in AEM is not getting reflected on the AEM site | AEM

Issue

Even after updating the code successfully in crx/de, the newly deployed sightly code does not reflect in the AEM site. The site still displays the older sightly code on some publish instances.

Environment

AEM 6.1, 6.2, 6.3

Cause

Since, the code is deployed properly to all the publish instances, the issue is with the recompilation of sightly code on a particular instance or instances.

Whenever a code deployment takes place on an AEM instance, the newly deployed code must force a recompile of the existing code when the associated page is requested. There is a known issue with Sightly[1], which does not properly detect the newly added code and therefore, it does not force a recompilation.

[1] https://issues.apache.org/jira/browse/SLING-6612

Resolution

The complete solution for this problem is available in the AEM release featuring the Scripting HTL Engine version 1.0.34. In the meantime, incorporate the following steps into the deployment process to ensure a uniform experience on all the AEM instances.

  • Place the script [2] in the AEM install directory and grant the AEM user privileges to execute it.
  • Go to the location, where the script is placed on AEM server and execute it using the following command. In the following example, the sample script is placed in the AEM install directory.
./cq-force-recompilation.sh crx-quickstart/ http://localhost:4526 admin:admin
  • The output looks as the following:
stopping the org.apache.sling.commons.fsclassloader bundle...​
deleting file  sytem  classes cache: /Users/ anearora /Desktop/AEM/6.2/TestServer/ crx -quickstart/launchpad/ felix /bundle305/data/classes ...
deleting /var/classes in the JCR...
starting the org.apache.sling.commons.fsclassloader bundle...

It clears out the previously compiled libraries and forces the updated libraries to compile when the associated page is requested.

[2] force-recompilation.sh

#!/bin/bash

if [[ $# -ne 3 || $1 == "-h" ]]; then
    echo "Usage: force-recompilation.sh <crx-quickstart-dir> <http://server:port> <user:password>"
    echo
    echo "Example arguments: crx-quickstart/ http://localhost:4502 admin:admin"
    echo
    echo "This will force a recompilation of all Sling scripts (jsps, java, sightly etc.)."
    exit
fi

dir="$1"
host="$2"
user="$3"

if [ ! -d "$dir/../crx-quickstart" ]; then
    echo "No crx-quickstart directory found."
    exit
fi

echo "stopping the org.apache.sling.commons.fsclassloader bundle..."
bundle="org.apache.sling.commons.fsclassloader"
curl -f -s -S -u $user -F action=stop  $host/system/console/bundles/$bundle > /dev/null
exitCode=$?
if [ $exitCode -ne 0 ]; then
    echo
    if [ $exitCode -eq 22 ]; then
        echo "Invalid admin password."
    fi
    echo "aborted.";
    exit
fi

cd "$dir"

classesDir=`find launchpad/felix -path "*/bundle*/data/classes" -type d`
if [ -d "$classesDir" ]; then
    echo "deleting file sytem classes cache: `pwd`/$classesDir ..."
    rm -rf "$classesDir"
else
    echo "file system classes cache empty or already cleared"
fi

echo "deleting /var/classes in the JCR..."
curl -f -s -S -u $user -X DELETE $host/var/classes > /dev/null

echo "starting the org.apache.sling.commons.fsclassloader bundle..."
curl -f -s -S -u $user -F action=start $host/system/console/bundles/$bundle > /dev/null
if [ $? -ne 0 ]; then
    echo
    echo "aborted, bundle was likely not restarted.";
    exit
fi

echo "done."

 Adobe

Få hjälp snabbare och enklare

Ny användare?