I haven't seen this problem at all with mandatory properties, and i don't see 
anything jumping out at me about your code (Altho i use the compact node type 
definition style). Is it possible that there still is some old version of your 
node type definition registered in the repository, that doesn't have the type 
property in it, and the new definition didn't get written?



-----Original Message-----
From: Jared Graber <[EMAIL PROTECTED]>
Sent: Friday, April 4, 2008 12:28pm
To: [email protected]
Subject: Mandatory Property Error

I defined this node type

 

    <nodeType name="my:orderable" isMixin="false"
hasOrderableChildNodes="true">

        <supertypes>

            <supertype>nt:unstructured</supertype>

        </supertypes>

        <propertyDefinition name="my:type" requiredType="String"
autoCreated="false" mandatory="true"

                            onParentVersion="COPY" protected="false"
multiple="false"/>

    </nodeType>

 

And this namespace

"my" -> "http://localhost";

 

 

This is my code:

Node parent = (Node) session.getItem(parentPath);

Node node = parent.addNode(JcrUtils.escapeName(nodeName),
"my:orderable");

node.addMixin("mix:referenceable");

node.setProperty("my:type", "image");

...

session.save();

 

 

I get the following exception:

javax.jcr.nodetype.ConstraintViolationException: /Top Level Category:
mandatory property {http://localhost}type does not exist

 

I specifically added the property, yet I'm still getting this exception.

 

I noticed this comment org.apache.jackrabbit.core.ItemImpl:

                        /**

                         * todo FIXME workaround for mix:versionable:

                         * the mandatory properties are initialized at a

                         * later stage and might not exist yet

                         */

 

Does this apply to all mandatory properties?

 

 

Any ideas on how to fix this problem?

 

Thanks,

 

Jared

 

 



Reply via email to