javax.jcr.nodetype.ConstraintViolationException: No matching property definition: PROPERTY

老子叫甜甜 提交于 2019-12-08 02:30:48

问题


When I am trying to set a property to my JCR node I am getting error

javax.jcr.nodetype.ConstraintViolationException: No matching property definition: PROPERTY.

I am a newbie to cq5. Please can someone help me to resolve this error?


回答1:


In jcr every node has a node-type (value of "jcr:primaryType").

Most node-types define a schema of properties that are allowed on that node. You cannot just add whatever property you like. It has to be defined in the schema. If you try to add and persist (commit) a property that is not defined, you get exactly this ConstraintViolationException.

So here's what likely happend: You've tried to create and store a property named "PROPERTY" on a node that has a strict schema, where that is not allowed.

If you provide more details what you tried to do exactly on what type of node, I may be able to pinpoint the problem.




回答2:


If you want to add property to a nt:file for exemple, you have to define a new mixin type and add it to your node.

This way you can add every properties you want

This simpler way is to create a CND file to define all your properties

<mc = 'http://myCompany.com/mc'>
[mc:fileProperties]
    mixin
        - mc:String1 (string)version
        - mc:String2 (string) version
        - mc:String3 (string) version
        - mc:LongString1 (string) version
        - mc:Date1 (date) version
        - mc:Date2 (date) version
        - mc:Number1 (long) version
        - mc:Number2 (long) version
        - mc:Boolean1 (boolean) version
        - mc:Boolean2 (boolean) version
        - mc:Choice1 (long) version

and you have to register your new mixin (you only have to do this once)

JackrabbitNodeTypeManager manager = (JackrabbitNodeTypeManager)session.getWorkspace().getNodeTypeManager();
InputStream cndFile = ... // Get you CND file
JackrabbitNodeTypeManager.TEXT_X_JCR_CND );

and add it to your Node

node.addMixin( "mc:fileProperties" );

Here you can do

node.setProperty( "mc:String1", "Toto" );
session.save();



回答3:


I had this problem in AEM while I using WKND tutorial. After download solution package, I installed chapter-8

org.apache.sling.ide.transport.RepositoryException: javax.jcr.nodetype.ConstraintViolationException: OakConstraint0004: /content/dam/wknd/en/contributors/stacey-roswells.jpg/jcr:content/renditions/cq5dam.thumbnail.140.100.png/jcr:content[[oak:Resource]]: No matching property definition found for jcr:uuid = 3f4b3593-7e5f-42a6-947a-80b67263469e Caused by: javax.jcr.nodetype.ConstraintViolationException: OakConstraint0004: /content/dam/wknd/en/contributors/stacey-roswells.jpg/jcr:content/renditions/cq5dam.thumbnail.140.100.png/jcr:content[[oak:Resource]]: No matching property definition found for jcr:uuid = 3f4b3593-7e5f-42a6-947a-80b67263469e

we can solve the problem if we remember to click on

aem-guides-wknd.ui.apps -> properties -> project facet -> REMOVE dynamic web module



来源:https://stackoverflow.com/questions/39305827/javax-jcr-nodetype-constraintviolationexception-no-matching-property-definition

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!