Hello,
I am trying to add property sling:configRef to a root page property through RepoInit Script in OSGI config. We are using AEM as cloud service and below is RepoInit script
RepoInit Script:
**********************************************************************
set properties on /content/myproject/us/jcr:content
set sling:configRef{String} to /conf/myprojectconfi
end
**********************************************************************
But with this above code, getting below error:
28.01.2022 11:22:44.141 *INFO* [Apache Sling Repository Startup Thread #1] org.apache.sling.jcr.repoinit.impl.NodePropertiesVisitor Setting properties on nodePath '/content/myproject/us/jcr:content'
28.01.2022 11:22:44.141 *ERROR* [Apache Sling Repository Startup Thread #1] com.adobe.granite.repository.impl.SlingRepositoryManager Exception in a SlingRepositoryInitializer, SlingRepository service registration aborted
java.lang.RuntimeException: Unable to set properties on path [/content/myproject/us/jcr:content]:javax.jcr.PathNotFoundException: Node with path /content/myproject/us/jcr:content does not exist.
at org.apache.sling.jcr.repoinit.impl.DoNothingVisitor.report(DoNothingVisitor.java:63) [org.apache.sling.jcr.repoinit:1.1.36]
at org.apache.sling.jcr.repoinit.impl.NodePropertiesVisitor.visitSetProperties(NodePropertiesVisitor.java:217) [org.apache.sling.jcr.repoinit:1.1.36]
at org.apache.sling.repoinit.parser.operations.SetProperties.accept(SetProperties.java:44) [org.apache.sling.repoinit.parser:1.6.10]
at org.apache.sling.jcr.repoinit.impl.JcrRepoInitOpsProcessorImpl.apply(JcrRepoInitOpsProcessorImpl.java:56) [org.apache.sling.jcr.repoinit:1.1.36]
at org.apache.sling.jcr.repoinit.impl.RepositoryInitializerFactory.lambda$applyOperations$0(RepositoryInitializerFactory.java:151) [org.apache.sling.jcr.repoinit:1.1.36]
at org.apache.sling.jcr.repoinit.impl.RetryableOperation.apply(RetryableOperation.java:57) [org.apache.sling.jcr.repoinit:1.1.36]
at org.apache.sling.jcr.repoinit.impl.RepositoryInitializerFactory.applyOperations(RepositoryInitializerFactory.java:149) [org.apache.sling.jcr.repoinit:1.1.36]
at org.apache.sling.jcr.repoinit.impl.RepositoryInitializerFactory.processRepository(RepositoryInitializerFactory.java:129) [org.apache.sling.jcr.repoinit:1.1.36]
at org.apache.sling.jcr.base.AbstractSlingRepositoryManager.executeRepositoryInitializers(AbstractSlingRepositoryManager.java:627) [org.apache.sling.jcr.base:3.1.10]
at org.apache.sling.jcr.base.AbstractSlingRepositoryManager.initializeAndRegisterRepositoryService(AbstractSlingRepositoryManager.java:575) [org.apache.sling.jcr.base:3.1.10]
at org.apache.sling.jcr.base.AbstractSlingRepositoryManager.access$300(AbstractSlingRepositoryManager.java:96) [org.apache.sling.jcr.base:3.1.10]
at org.apache.sling.jcr.base.AbstractSlingRepositoryManager$4.run(AbstractSlingRepositoryManager.java:544) [org.apache.sling.jcr.base:3.1.10]
Caused by: javax.jcr.PathNotFoundException: Node with path /content/myproject/us/jcr:content does not exist.
at org.apache.jackrabbit.oak.jcr.session.SessionImpl.getNode(SessionImpl.java:341) [org.apache.jackrabbit.oak-jcr:1.40.0.T20220110121513-be5e04f]
at com.adobe.granite.repository.impl.CRX3SessionImpl.getNode(CRX3SessionImpl.java:185) [com.adobe.granite.repository:1.8.8]
at org.apache.sling.jcr.repoinit.impl.NodePropertiesVisitor.setNodeProperties(NodePropertiesVisitor.java:185) [org.apache.sling.jcr.repoinit:1.1.36]
at org.apache.sling.jcr.repoinit.impl.NodePropertiesVisitor.visitSetProperties(NodePropertiesVisitor.java:214) [org.apache.sling.jcr.repoinit:1.1.36]
... 10 common frames omitted
and there is way to create /content/myproject/jcr:content using script:
create path /content/myproject/jcr:content
Will this create jcr:content node on every deployment on AEM as CS environment ?
Solved! Go to Solution.
@pradeepmoolemane - Please follow the below steps to create a repoinit script in AEMaaCS:
{
"scripts": [
"create path (cq:Page) /content/<myproject>",
"create path (cq:PageContent) /content/<myproject>/jcr:content",
"create path (cq:Page) /content/<myproject>/us",
"create path (cq:PageContent) /content/<myproject>/us/jcr:content",
"set properties on /content/<myproject>/us/jcr:content\n set sling:configRef{String} to /conf/myprojectconfig\nend",
]
}
This script can further be optimized and more details can be found here: https://sling.apache.org/documentation/bundles/repository-initialization.html
Jineet
Have you created as json.cfg file? Also, json.cfg does not support multi line script so please try to move it to single line and check.
@pradeepmoolemane - Please follow the below steps to create a repoinit script in AEMaaCS:
{
"scripts": [
"create path (cq:Page) /content/<myproject>",
"create path (cq:PageContent) /content/<myproject>/jcr:content",
"create path (cq:Page) /content/<myproject>/us",
"create path (cq:PageContent) /content/<myproject>/us/jcr:content",
"set properties on /content/<myproject>/us/jcr:content\n set sling:configRef{String} to /conf/myprojectconfig\nend",
]
}
This script can further be optimized and more details can be found here: https://sling.apache.org/documentation/bundles/repository-initialization.html
Jineet
Views
Likes
Replies