jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jared Graber" <jared.gra...@IACcap.com>
Subject RE: Mandatory Property Error
Date Fri, 04 Apr 2008 18:19:15 GMT
It's not possible that there is an old version of my node type definition.

I am running the code as a standalone unit test.
Each test creates a new transient repository during setup, and destroys it (and deletes the
associated files) during cleanup.
The way the tests are written, they will fail prematurely if there is an existing repository.

The sequence of events in the test:
1.  Create a new repository
2.  Register node types and namespaces
3.  Insert a node and save

The error occurs during the save operation.

While debugging I found that the node type seems to be correct (it has the required types),
and that the error is occurring while validating Transient Items.  The node state apparently
doesn't have the mandatory property.  I don't understand why it's not in the state as it is
explicitly added to the node before the save method is called.

-Jared

-----Original Message-----
From: Dave Brosius [mailto:dbrosius@mebigfatguy.com] 
Sent: Friday, April 04, 2008 2:01 PM
To: users@jackrabbit.apache.org
Subject: RE: Mandatory Property Error

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 <jared.graber@IACcap.com>
Sent: Friday, April 4, 2008 12:28pm
To: users@jackrabbit.apache.org
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

 

 



Mime
View raw message