Skip to content

Instantly share code, notes, and snippets.

@aitseitz
Last active March 12, 2024 10:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save aitseitz/89fbd80bb63fa38c3f13449f3df15ec3 to your computer and use it in GitHub Desktop.
Save aitseitz/89fbd80bb63fa38c3f13449f3df15ec3 to your computer and use it in GitHub Desktop.
ACS: How to downgrade an AMP-Module like alfresco-aos-module
// Based on Tech Article:
// https://community.hyland.com/tskb/000013140-how-to-downgrade-the-outlook-integration-module-after-installing-unsupported-amp-version
// the correct uuid for the amp module needs to be identified via the node browser inside the system://system Store
var sysNodeUUID = "system://system/8b6df670-9bb3-462b-8483-9b156e2621fd";
var newVersionString = "1.0.0";
/**
* Searches for the target node and sets a fix Version for "module:currentVersion"
* @param sysNodeUUID {String} module node string e.g. "system://system/uuid"
* @param newVersionString {String} the version which will be set for the target node
*/
function setFixModuleVersion(sysNodeUUID, newVersionString) {
var targetNode = search.findNode(sysNodeUUID);
if (targetNode) {
logger.log("Fixing Module Version for '" + targetNode.properties["cm:name"] + "':");
logger.log("Module '" + targetNode.properties["cm:name"] + "' (before change) Version = " + targetNode.properties["module:currentVersion"]);
targetNode.properties["module:currentVersion"] = newVersionString;
targetNode.save();
logger.log("Module '" + targetNode.properties["cm:name"] + "' (after change) Version = " + targetNode.properties["module:currentVersion"]);
} else {
logger.error("Target Node not found in for " + sysNodeUUID);
}
}
setFixModuleVersion(sysNodeUUID, newVersionString);
ERROR [org.springframework.web.context.ContextLoader] [localhost-startStop-1] Context initialization failed
org.alfresco.error.AlfrescoRuntimeException: 06060023 Failed to start modules
at org.alfresco.repo.module.ModuleComponentHelper$1.doWork(ModuleComponentHelper.java:326)
at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:602)
at org.alfresco.repo.module.ModuleComponentHelper.startModules(ModuleComponentHelper.java:213)
at org.alfresco.repo.module.ModuleServiceImpl.startModules(ModuleServiceImpl.java:149)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
at com.sun.proxy.$Proxy154.startModules(Unknown Source)
at org.alfresco.repo.module.ModuleStarter$1.execute(ModuleStarter.java:73)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:450)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:338)
at org.alfresco.repo.module.ModuleStarter$2.doWork(ModuleStarter.java:83)
at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:602)
at org.alfresco.repo.module.ModuleStarter.onBootstrap(ModuleStarter.java:78)
at org.springframework.extensions.surf.util.AbstractLifecycleBean.onApplicationEvent(AbstractLifecycleBean.java:56)
at org.alfresco.repo.management.SafeApplicationEventMulticaster.multicastEventInternal(SafeApplicationEventMulticaster.java:221)
at org.alfresco.repo.management.SafeApplicationEventMulticaster.multicastEvent(SafeApplicationEventMulticaster.java:186)
at org.alfresco.repo.management.SafeApplicationEventMulticaster.multicastEvent(SafeApplicationEventMulticaster.java:206)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:359)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:896)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:401)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:292)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
at org.alfresco.web.app.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:70)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4705)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5168)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:743)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:719)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:672)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1873)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.alfresco.error.AlfrescoRuntimeException: 06060022
Downgrading of modules is not supported.
Module 'alfresco-aos-module' version 1.3.2.1 is currently installed and must be uninstalled before version 1.3.0 can be installed.
at org.alfresco.error.AlfrescoRuntimeException.create(AlfrescoRuntimeException.java:52)
at org.alfresco.repo.module.ModuleComponentHelper.startModule(ModuleComponentHelper.java:633)
at org.alfresco.repo.module.ModuleComponentHelper.access$5(ModuleComponentHelper.java:530)
at org.alfresco.repo.module.ModuleComponentHelper$1$1.execute(ModuleComponentHelper.java:263)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:450)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:338)
at org.alfresco.repo.module.ModuleComponentHelper$1.doWork(ModuleComponentHelper.java:284)
... 46 more
-- Alternative solution --> Delete AMP Module row from DB:
-- Select AOS Module Row
SELECT * FROM
alf_node_properties prop,
alf_qname qname,
alf_namespace ns,
alf_node_properties prop2
WHERE
prop.qname_id = qname.id
and qname.ns_id = ns.id
and prop2.node_id = prop.node_id
and qname.local_name='currentVersion'
and ns.uri='http://www.alfresco.org/system/modules/1.0'
and prop2.string_value='alfresco-aos-module'
-- Delete AOS AMP row from PostgreSQL Database
DELETE FROM
alf_node_properties prop
USING
alf_qname qname,
alf_namespace ns,
alf_node_properties prop2
where
prop.qname_id = qname.id
and qname.ns_id = ns.id
and prop2.node_id = prop.node_id
and qname.local_name='currentVersion'
and ns.uri='http://www.alfresco.org/system/modules/1.0'
and prop2.string_value='alfresco-aos-module'
@aitseitz
Copy link
Author

aitseitz commented Jul 6, 2021

Resetting an AMP Guide as workaround for MNT-22303

This knowledge article describes one option to reset the version of on installed AMP. This only works if the AMP itself does not have incremental model changes!

In the latest AOS v1.3.2 for ACS 6.2.2 exists a bug which prevents users to create files over network drive:
image

--> https://alfresco.atlassian.net/browse/MNT-22303

Prefered Solution:
--> Upgrade to AOS v.1.3.3 or higher
At the time of writing this article, the bugfixed version v.1.3.3 from Alfresco is in pipe and not yet available at the time of writing this article.

Current Workaround:
--> Downgrade to AOS v1.3.0 or AOS v1.3.1
(AOS 1.3.1 is only available via Nexus, not via hyland support portal)

image

When you downgrade to AOS v.1.3.0 you'll end up getting this error in the alfresco.log

Caused by: org.alfresco.error.AlfrescoRuntimeException: 06060022 
Downgrading of modules is not supported.
Module 'alfresco-aos-module' version 1.3.2.1 is currently installed and must be uninstalled before version 1.3.0 can be installed.

How to reset AOS AMP Module Version (via Share)

Info: the steps describes are based on technical article
https://community.hyland.com/tskb/000013140-how-to-downgrade-the-outlook-integration-module-after-installing-unsupported-amp-version

Prequirements:
Java-Script Console Plugin should be installed in share https://github.com/share-extras/js-console

  1. Stop ACS
    For exmple:

    $ sudo systemctl stop acs.service
    $ sudo systemctl stop ass.service
    
  2. Uninstall the current version of the alfresco-aos-module via alfresco-mmt.jar:

    $ java -jar alfresco-mmt.jar list /home/teak01/content-services/tomcat/webapps/alfresco
    $ java -jar alfresco-mmt.jar uninstall alfresco-aos-module /home/teak01/content-services/tomcat/webapps/alfresco
    
  3. Start ACS you'll see the following output in alfresco.log:

    WARN  [org.alfresco.repo.module.ModuleServiceImpl] [localhost-startStop-1] A previously-installed module 'alfresco-aos-module' (version 1.3.2.1) is not present in your distribution.
    
  4. Navigate to the Module Registry via NodeBrowser (System://System Store)
    image

  5. Locate the module:alfresco-aos-module in /sys:system-registry/module:modules

  6. The "module:currentVersion" property specifies the version of the module against which the new installed version is compared at system startup.
    image

  7. Copy the full system UUID of the module
    In our case that's
    "system://system/76c99fa4-675e-46e0-93e4-6d2239ec91a9"

  8. Insert the system UUID into the [acs_downgrade_amp_module.js]
    --> Reset AMP Version String to something lower then 1.3.2
    (https://gist.github.com/aitseitz/89fbd80bb63fa38c3f13449f3df15ec3#file-acs_downgrade_amp_module-js)

  9. Execute the acs_downgrade_amp_module.js in the Java-Script Console
    image

  10. Verify the change in NodeBrowser:
    image

  11. Stop ACS

  12. Install the AOS v.1.3.0 with apply_amps.sh or directly via alfresco-mmt.jar

    $ java -jar alfresco-mmt.jar install  /path/to/alfresco-aos-module-1.3.0.amp /home/teak01/content-services/tomcat/webapps/alfresco
    $ java -jar alfresco-mmt.jar list /home/teak01/content-services/tomcat/webapps/alfresco
    

Details see: https://docs.alfresco.com/content-services/6.2/develop/extension-packaging/#using-the-module-management-tool-mmt

  1. Start ACS you'll get the following message in alfresco.log
INFO  [org.alfresco.repo.module.ModuleServiceImpl] [localhost-startStop-1] Upgrading module 'alfresco-aos-module' version 1.3.0 (was 1.0.0).
INFO  [org.alfresco.repo.module.ModuleServiceImpl] [localhost-startStop-1] Starting module 'alfresco-aos-module' version 1.3.0.

How to reset AMP Module Version (via SQL):

Alternative solution is to remove the whole AMP Module row from the DB with the following SQL (for PostgreSQL):

removeAMPVersionString.sql

The difference is that manually deleting rows in the db can be be a higher risk (so make a backup befor you do so). After the amp row was deleted and you boot up acs again in the alfresco.log the information that a previous module version was installed is missing...

INFO  [org.alfresco.repo.module.ModuleServiceImpl] [localhost-startStop-1] Installing module 'alfresco-aos-module' version 1.3.0.

@hi-ko
Copy link

hi-ko commented Jul 15, 2021

easier approach: use the node browser from the admin console (not share) and just delete the module registration. It will be recreated once alfresco restarts.

You could do this also by a javascript like:

var searchString = "/sys:system-registry/module:modules/*"; // XPath search string
var store = "system://system";
var nodes = search.selectNodes(store, searchString);

for each (var node in nodes) {
logger.log("removing entry for module: " + node.name);
    node.addAspect("sys:temporary");
    node.remove();
}

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