Expand my Community achievements bar.

How to deal with RepoInit failures in Cloud Service | AEM Community Blog Seeding

Avatar

Administrator

BlogImage.jpg

How to deal with RepoInit failures in Cloud Service by Jörg Hoh

Abstract

Some years, even before AEM as a Cloud Services, the RepoInit language has been implemented as part of Sling (and AEM) to create repository structures directly on the startup of the JCR Repository. With it your application can rely that some well-defined structures are always available.

In this blog post I want to walk you through a way how you can test repoinit statements locally and avoid pipeline failures because of it.

Repoinit statements are deployed as part of OSGI configurations; and that means that during the development phase you can work in an almost interactive way with it. Also exceptions are not a problem; you can fix the statement and retry.

The situation is much different when you already have repoinit statements deployed and you startup your AEM (to be exact: the Sling Repository service) again. Because in this case all repoinit statements are executed as part of the startup of the repository. And any exception in the execution of repoinits will stop the startup of the repository service and render your AEM unusable. In the case of CloudManager and AEM as a Cloud Service this will break your deployment.

Let me walk you through 2 examples of such an exception and how you can deal with it.

*ERROR* [Apache SlingRepositoryStartup Thread #1] com.adobe.granite.repository.impl.SlingRepositoryManager Exception in a SlingRepositoryInitializer, SlingRepositoryservice registration aborted java.lang.RuntimeException: Session.save failed: javax.jcr.nodetype.ConstraintViolationException: OakConstraint0025: /conf/site/configuration/favicon.ico[[nt:file]]: Mandatory child node jcr:content not found in a new node
at org.apache.sling.jcr.repoinit.impl.AclVisitor.visitCreatePath(AclVisitor.java:167) [org.apache.sling.jcr.repoinit:1.1.36]
at org.apache.sling.repoinit.parser.operations.CreatePath.accept(CreatePath.java:71)
In this case the exception is quite detailed what actually went wrong. It failed when saving, and it says that /conf/site/configuration/favicon (of type nt:file) was affected. The problem is that a mandatory child node “jcr:content” is missing.

Why is it a problem? Because every node of nodetype “nt:file” requires a “jcr:content” child node which actually holds the binary.

This is a case which you can detect very easily also on a local environment.

Which leads to the first recommendation: When you develop in your local environment, you should apply all repoinit statements to a fresh environment, in which there are no manual changes. Because otherwise your repoinit statements rely on the presence of some things which are not provided by the repoinit scripts.

Having a mix of manual changes and repoinit on a local development environment and then moving it untested over is often leads to failures in the CloudManager pipelines.

Read Full Blog

How to deal with RepoInit failures in Cloud Service

Q&A

Please use this thread to ask the related questions.



Kautuk Sahni
1 Reply

Avatar

Level 2

Hello @kautuk_sahni 

I am facing a similar exception, how could I avoid it. Here is the exception I am facing :

[repoinit] repoinit: Parsing error in repoinit from extension : org.apache.sling.repoinit.parser.impl.ParseException: Encountered "" at line 185, column 2.
Was expecting one of:

Here's the script I am trying to run :
{
"scripts": [
"# Create group & Set Permission to ga_AEM_YYYYYY_ContentAuthors_PRD group\n create group ga_AEM_YYYYYY_ContentAuthors_PRD\n set ACL for ga_AEM_YYYYYY_ContentAuthors_PRD\n allow jcr:read on /\n deny crx:replicate on /content\n allow jcr:versionManagement, rep:write, jcr:lockManagement on /content\n allow jcr:read, jcr:versionManagement, rep:write, jcr:lockManagement on /etc\n allow jcr:read, jcr:versionManagement, rep:write, jcr:lockManagement on /var\n end",
"# Create group & Set Permission to ga_AEM_YYYYYY_ContentApprovers_PRD group\n create group ga_AEM_YYYYYY_ContentApprovers_PRD\n set ACL for ga_AEM_YYYYYY_ContentApprovers_PRD\n allow jcr:read on /\n deny crx:replicate on /conf\n allow jcr:versionManagement, rep:write, jcr:lockManagement on /content\n allow jcr:read, jcr:versionManagement, rep:write, jcr:lockManagement on /etc\n allow jcr:read, jcr:versionManagement, rep:write, jcr:lockManagement on /var\n end",
"# Create group & Set Permissions to ga_AEM_YYYYYY_ContentReviewerLegal_PRD group\n create group ga_AEM_YYYYYY_ContentReviewerLegal_PRD\n set ACL for ga_AEM_YYYYYY_ContentReviewerLegal_PRD\n allow jcr:read on /\n allow jcr:read, jcr:versionManagement, rep:write, jcr:lockManagement on /etc\n allow jcr:read, jcr:versionManagement, rep:write, jcr:lockManagement on /var\n end",
"# Create Service User\n create service user toyotaWorkflowUser\n set ACL on /libs,/content,/conf,/etc\n allow jcr:all for toyotaWorkflowUser\n end",
"# Create group & Set Permission to ga_AEM_ZZZZZZ_YYYYYY_Content_Author_PRD group\n create group ga_AEM_ZZZZZZ_YYYYYY_Content_Author_PRD\n set ACL for ga_AEM_ZZZZZZ_YYYYYY_Content_Author_PRD\n create path /content/powertorque\n allow jcr:read on /var/workflow/models\n deny jcr:read on /var/workflow/models restriction(rep:glob,/scheduled_tree_activation/)\n deny jcr:read on /var/workflow/models restriction(rep:glob,/scheduled_activation_with_references/)\n allow jcr:read on /\n deny crx:replicate on /content/powertorque\n allow jcr:versionManagement, rep:write, jcr:lockManagement on /content/powertorque\n allow jcr:read, jcr:versionManagement, rep:write, jcr:lockManagement on /etc\n allow jcr:read, jcr:versionManagement, rep:write, jcr:lockManagement on /var\n end",
"# Create group ga_AEM_ZZZZZZ_YYYYYY_Content_Approver_PRD\n create group ga_AEM_ZZZZZZ_YYYYYY_Content_Approver_PRD\n set ACL for ga_AEM_ZZZZZZ_YYYYYY_Content_Approver_PRD\n allow jcr:read on /\n deny crx:replicate on /conf\n allow jcr:read, rep:write, jcr:lockManagement, jcr:versionManagement on /var\n deny jcr:all on /content/powertorque\n deny jcr:all on /etc/workflow/models\n allow jcr:read on /content/experience-fragments/powertorque\n deny jcr:all on /content/experience-fragments/powertorque\n end",
"# Create group & Set Permissions to ga_AEM_ZZZZZZ_YYYYYY_Global_Admin_PRD\n create group ga_AEM_ZZZZZZ_YYYYYY_Global_Admin_PRD\n set ACL for ga_AEM_ZZZZZZ_YYYYYY_Global_Admin_PRD\n allow jcr:all on /content/experience-fragments/powertorque\n allow jcr:all on /content/dam/powertorque\n allow jcr:all on /\n allow jcr:all on /content/powertorque\n allow jcr:all on /etc\n allow jcr:all on /var\n allow jcr:all on /conf\n end",
"# Create group ga_AEM_ZZZZZZ_XXXXXX_Content_Approver_PRD\n create group ga_AEM_ZZZZZZ_XXXXXX_Content_Approver_PRD\n set ACL for ga_AEM_ZZZZZZ_XXXXXX_Content_Approver_PRD\n allow jcr:read on /\n deny crx:replicate on /conf\n allow jcr:read, rep:write, jcr:lockManagement, jcr:versionManagement on /var\n deny jcr:all on /content/XXXXXX\n deny jcr:all on /etc/workflow/models\n allow jcr:read on /content/experience-fragments/XXXXXX\n deny jcr:all on /content/experience-fragments/XXXXXX\n end",
"# Create group & Set Permissions to ga_AEM_ZZZZZZ_XXXXXX_Global_Admin_PRD\n create group ga_AEM_ZZZZZZ_XXXXXX_Global_Admin_PRD\n set ACL for ga_AEM_ZZZZZZ_XXXXXX_Global_Admin_PRD\n allow jcr:all on /content/experience-fragments/XXXXXX\n allow jcr:all on /content/dam/XXXXXX\n allow jcr:all on /\n allow jcr:all on /content/XXXXXX\n allow jcr:all on /etc\n allow jcr:all on /var\n allow jcr:all on /conf\n end",
"# Create group ga_AEM_ZZZZZZ_PAF_Content_Approver_PRD\n create group ga_AEM_ZZZZZZ_PAF_Content_Approver_PRD\n set ACL for ga_AEM_ZZZZZZ_PAF_Content_Approver_PRD\n allow jcr:read on /\n deny crx:replicate on /conf\n allow jcr:read, rep:write, jcr:lockManagement, jcr:versionManagement on /var\n deny jcr:all on /content/paf\n deny jcr:all on /etc/workflow/models\n allow jcr:read on /content/experience-fragments/paf\n deny jcr:all on /content/experience-fragments/paf\n end",
"# Create group & Set Permissions to ga_AEM_ZZZZZZ_PAF_Global_Admin_PRD\n create group ga_AEM_ZZZZZZ_PAF_Global_Admin_PRD\n set ACL for ga_AEM_ZZZZZZ_PAF_Global_Admin_PRD\n allow jcr:all on /content/experience-fragments/paf\n allow jcr:all on /content/dam/paf\n allow jcr:all on /\n allow jcr:all on /content/paf\n allow jcr:all on /etc\n allow jcr:all on /var\n allow jcr:all on /conf\n end"
]
}