Expand my Community achievements bar.

SOLVED

Custom Node Type not being added with .cnd file

Avatar

Level 3

I added a custom node type to the nodetypes.cnd file.  That file is in the META-INF/vault folder.  When the package is built, I cannot find this file in the package.  Is that a problem?  If so, where should this file be copied to?  To test if this may be the issue, I manually added the nodetypes.cnd file to the META-IN/vault folder of the package, but this did not solve the problem either.  I had successfully use a nodetype.cnd file a few months ago with AEM 6.0 to add a new namespace.  I am having an issue doing this now.  This time I an using AEM 6.1.

 

Contents of the nodetypes.cnd file: 

<'testXmpExt'='testXmpExt>

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Did you also installed this file using package manager. If you just created this file manually then it won't work. To test your use case, I created a package with this file in AEM 6.1 and installed this package. Package installation logs below shows that it is installing new new node types- 

Installing node types... - sling -> http://sling.apache.org/jcr/sling/1.0 - nt -> http://www.jcp.org/jcr/nt/1.0 A testXmpExt -> testXmpExt - rep -> internal - sling:Folder - rep:RepoAccessControllable Installing privileges... 

Also, after this step I checked the node type administration page and I could see the new namespace registered.  - http://localhost:4502/crx/explorer/ui/namespace_editor.jsp?Path=&Callback=reload

View solution in original post

10 Replies

Avatar

Employee

Did you include the meta-inf folder in your resource element to be included in your bundle?

<build>

        <resources>
            <resource>
                <directory>src/main/content/jcr_root</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>**/.vlt</exclude>
                    <exclude>**/.vltignore</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>src/main/content/META-INF/vault</directory>
                <targetPath>../vault-work/META-INF/vault</targetPath>
            </resource>
        </resources>

Avatar

Employee Advisor

I think the META-INF/vault location works when you include the cnd file as part of the OSGI bundle and configure the maven-bundle plugin for the same. But to install it using the package manager you can just include this file as normal content in any folder. For example, you can define filters in your package to deploy this file to /apps/<project>/nodetypes/nodetypes.cnd

Avatar

Level 3

I tried adding this file under /apps/testproject/nodetype and it still didn't work.

Avatar

Employee Advisor

I think the contents of the file are not right as per CND file notations. Can you check the documentation here and verify - https://jackrabbit.apache.org/jcr/node-type-notation.html

Avatar

Level 3

I tried both of the following and neither worked.

<'testXmpExt'='testXmpExt'>

<testXmpExt='testXmpExt'>

Avatar

Correct answer by
Employee Advisor

Did you also installed this file using package manager. If you just created this file manually then it won't work. To test your use case, I created a package with this file in AEM 6.1 and installed this package. Package installation logs below shows that it is installing new new node types- 

Installing node types... - sling -> http://sling.apache.org/jcr/sling/1.0 - nt -> http://www.jcp.org/jcr/nt/1.0 A testXmpExt -> testXmpExt - rep -> internal - sling:Folder - rep:RepoAccessControllable Installing privileges... 

Also, after this step I checked the node type administration page and I could see the new namespace registered.  - http://localhost:4502/crx/explorer/ui/namespace_editor.jsp?Path=&Callback=reload

Avatar

Level 3

I installed the package using package manager.  Can you attach the package that you created so I can compare it to mine?

Avatar

Employee Advisor

I tested the attached package. Change the extension to ".zip" after download.

Avatar

Level 3

The package you provided installed fine.  I tweaked mine and it now seems to work.  The nodetypes.cnd file in the META-INF/vault folder has the following contents.  At first I added another cnd file under apps/shared/nodetypes, but I didn't end up needing it.  Thanks for the help.

<'sling'='http://sling.apache.org/jcr/sling/1.0'>
<'nt'='http://www.jcp.org/jcr/nt/1.0'>
<'rep'='internal'>
<'testXmpExt'='testXmpExt'>

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

[rep:RepoAccessControllable]
  mixin
  + rep:repoPolicy (rep:Policy) protected ignore