Not able to Add OOTB groups to newly created groups via repoinit script | Community
Skip to main content
khamat_bn
Level 4
March 27, 2021
Solved

Not able to Add OOTB groups to newly created groups via repoinit script

  • March 27, 2021
  • 3 replies
  • 2283 views

We have written a repoinit script to add OOTB groups to custom groups but getting the error in script while deploying to AEM cloud.(working fine in local) 

That is because of script is running earlier than the OOTB group creation. Its failing while building image in cloud. 

So we want to add OOTB groups to custom groups automatically instead of manually. 

Is there any way instead of manual work ?

 

Below are logs for build image execution in AEM cloud pipeline.

 

 

27.01.2021 06:19:54.906 *INFO* [Apache Sling Repository Startup Thread #1] org.apache.sling.jcr.repoinit.impl.GroupMembershipVisitor Adding members '[global-librarian, asset-consumers]' to group 'contributor' 

27.01.2021 06:19:54.911 *ERROR* [Apache Sling Repository Startup Thread #1] com.adobe.granite.repository.impl.SlingRepositoryManager Exception in a SlingRepositoryInitializer, SlingRepository service registration aborted 

java.lang.RuntimeException: contributor is not a group 

at org.apache.sling.jcr.repoinit.impl.GroupMembershipVisitor.visitAddGroupMembers(GroupMembershipVisitor.java:52) [org.apache.sling.jcr.repoinit:1.1.28] 

at org.apache.sling.repoinit.parser.operations.AddGroupMembers.accept(AddGroupMembers.java:40) [org.apache.sling.repoinit.parser:1.6.2] 

at org.apache.sling.jcr.repoinit.impl.JcrRepoInitOpsProcessorImpl.apply(JcrRepoInitOpsProcessorImpl.java:56) [org.apache.sling.jcr.repoinit:1.1.28] 

at org.apache.sling.jcr.repoinit.impl.RepositoryInitializerFactory.processRepository(RepositoryInitializerFactory.java:126) [org.apache.sling.jcr.repoinit:1.1.28] 

at org.apache.sling.jcr.base.AbstractSlingRepositoryManager.executeRepositoryInitializers(AbstractSlingRepositoryManager.java:610) [org.apache.sling.jcr.base:3.1.6] 

at org.apache.sling.jcr.base.AbstractSlingRepositoryManager.initializeAndRegisterRepositoryService(AbstractSlingRepositoryManager.java:558) [org.apache.sling.jcr.base:3.1.6] 

at org.apache.sling.jcr.base.AbstractSlingRepositoryManager.access$300(AbstractSlingRepositoryManager.java:92) [org.apache.sling.jcr.base:3.1.6] 

at org.apache.sling.jcr.base.AbstractSlingRepositoryManager$4.run(AbstractSlingRepositoryManager.java:527) [org.apache.sling.jcr.base:3.1.6] 

27.01.2021 06:19:54.918 *INFO* [Apache Sling Repository Startup Thread #1] com.adobe.granite.repository.impl.SlingRepositoryManager Stop requested 

 

Contributor group is creating after running repoinit script 

 

27.01.2021 06:20:07.751 *INFO* [Apache Sling Repository Startup Thread #1] com.adobe.granite.security.user.internal.audit.AuditAuthorizableAction Group 'contributor' was created 

27.01.2021 06:20:07.780 *WARN* [Apache Sling Repository Startup Thread #1] org.apache.jackrabbit.oak.security.user.UserImporter New member of Group 'contributor': No such authorizable (NodeID = 429bbd5b-46a6-3c3d-808b-5fd4219d5c4d) 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by user05162

Repoint does initialize before any content[1] is loaded to the repo. So, you will have to find an alternate approach to add the OOTB group to the custom group.

 

One approach I could think of is to do it via custom code when your code initializes for the first time after AEM restart 

 

[1] https://experienceleague.adobe.com/docs/experience-manager-cloud-service/implementing/deploying/overview.html?lang=en#repoinit

 

3 replies

arunpatidar
Community Advisor
Community Advisor
March 28, 2021

you can write this logic in your bundle as well, on bundle activator class.

As soon s the bundle is activated, it will add a custom group to the contributor group.

Arun Patidar
user05162Adobe EmployeeAccepted solution
Adobe Employee
March 29, 2021

Repoint does initialize before any content[1] is loaded to the repo. So, you will have to find an alternate approach to add the OOTB group to the custom group.

 

One approach I could think of is to do it via custom code when your code initializes for the first time after AEM restart 

 

[1] https://experienceleague.adobe.com/docs/experience-manager-cloud-service/implementing/deploying/overview.html?lang=en#repoinit

 

June 16, 2021

So as to add OOTB groups to newly created groups via repoinit script follow below steps:

 

1. Create OOTB group via repoinit script

2. ADD  OOTB group to newly created custom group

3. Once AEM loads, OOTB groups permission will be automatically taken care off.

 

scripts=[
"
create group contributor

create group new-custom-group
add new-custom-group to group contributor
"
]

 

kautuk_sahni
Community Manager
Community Manager
June 17, 2021
@ashwinkumar_gupta, Thank you for sharing the answer with AEM community. Keep it up.
Kautuk Sahni