Expand my Community achievements bar.

SOLVED

AEM 6: How to install namespaces automaticaly?

Avatar

Level 7

Over the time some new meta tags found the way into some programs which can edit media files. When some files added to AEM, the creation process for packages breaks with a javax.jcr.NamespaceException. I found https://experienceleague.adobe.com/docs/experience-cloud-kcs/kbarticles/KA-16465.html?lang=en to add the missing namespaces manually.

My question: In case the instance has to be renewed, how can be the missing names provided during package installation?

 

Thanks in advanced

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Could you please explore via CND File as described at https://techrevel.blog/2020/01/23/aem-custom-namespace/


The CND File way has a advantage, that the namespace will be automatically registered on deploying code.

Create a nodetypes.cnd at the location /src/main/content/META-INF/vault/nodetypes.cnd
Register you namespace as shown in the example below
<'sling'='http://sling.apache.org/jcr/sling/1.0'&gt;
<'nt'='http://www.jcp.org/jcr/nt/1.0'&gt;
<'techrevel'='http://www.techrevel.blog'&gt;

[sling:Folder] > nt:folder
– * (undefined)
– * (undefined) multiple
+ * (nt:base) = sling:Folder version

 

Once you deploy the code, the namespace would be available for use.

 

I could see nodetypes.cnd is available at aem-demo\ui.frontend\node_modules\aemsync\data\package-content\META-INF\vault\nodetypes.cnd [my sample aem application]. Please check nodetypes.cnd in your project.

 

namespaces are getting stored under /jcr:system/rep:namespaces as shown below -

 

DEBAL_DAS_1-1649943118262.png

 

We could create a separate package for namespaces and install.

Hope it will help.

View solution in original post

5 Replies

Avatar

Correct answer by
Employee Advisor

Could you please explore via CND File as described at https://techrevel.blog/2020/01/23/aem-custom-namespace/


The CND File way has a advantage, that the namespace will be automatically registered on deploying code.

Create a nodetypes.cnd at the location /src/main/content/META-INF/vault/nodetypes.cnd
Register you namespace as shown in the example below
<'sling'='http://sling.apache.org/jcr/sling/1.0'&gt;
<'nt'='http://www.jcp.org/jcr/nt/1.0'&gt;
<'techrevel'='http://www.techrevel.blog'&gt;

[sling:Folder] > nt:folder
– * (undefined)
– * (undefined) multiple
+ * (nt:base) = sling:Folder version

 

Once you deploy the code, the namespace would be available for use.

 

I could see nodetypes.cnd is available at aem-demo\ui.frontend\node_modules\aemsync\data\package-content\META-INF\vault\nodetypes.cnd [my sample aem application]. Please check nodetypes.cnd in your project.

 

namespaces are getting stored under /jcr:system/rep:namespaces as shown below -

 

DEBAL_DAS_1-1649943118262.png

 

We could create a separate package for namespaces and install.

Hope it will help.

Avatar

Level 7

Thanks for your answer. I tried it out immeditly. I added the file to an existing package. During package building I get the error message "[ERROR] Request failed: java.lang.IllegalStateException: Archive not valid. (500)".  What is wrong?


 

Avatar

Level 7

I could fix it. The file name is not correct. It must be "nodetype", the singular form. After correction it works like a charm.

 

Thanks a lot..

Avatar

Employee Advisor

Great observation and thanks for your input. While exploring your requirement I have noticed  nodetypes.cnd in my sample application and this file[named:nodetypes.cnd] was created during initial project setup.

Avatar

Level 7

On filesystem tin folder /content/META-INF/vault exists a file called settings.xml. In this you can find the name "nodetype".