jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kaizer <Kaiz...@mastek.com>
Subject Re: Problem adding a child node
Date Tue, 04 Sep 2007 04:19:38 GMT

Hi,

Thanks a lot. Actually earlier I was trying to add the node under nt:folder
and was getting the same exception, thats why i tried using the base node
type. Why cant i add the nodes with nt:folder as the node type and what
exactly is the cause of this exception?

Thanks!




Stefan Guggisberg wrote:
> 
> On 9/3/07, Kaizer <Kaizers@mastek.com> wrote:
>>
>> I am getting a similar exception on adding nodes.
>>
>> Node hello = root.addNode("hello","nt:base");
>> Node world = hello.addNode("world","nt:base");
>>
>> javax.jcr.nodetype.ConstraintViolationException: no definition found in
>> parent node's node type for new node: no matching child node definition
>> found for {}world: no matching child node definition found for {}world
>>
>> What should i do in this case?
> 
> nt:base is not intended to be used directly as a node type. it serves as
> the
> root of the node type hierarchy and just defines the 2 properties common
> to all nodes: jcr:primaryType and jcr:mixinTypes.
> 
> in your example, you could either omit the 2nd parameter (assuming the
> default)
> or specify an appropriate node type. nt:unstructured is the most
> generic node type,
> it allows any child nodes and any property of any type.
> 
> Node hello = root.addNode("hello");
> Node world = hello.addNode("world");
> 
> or
> 
> Node hello = root.addNode("hello","nt:unstructured");
> Node world = hello.addNode("world","nt:unstructured");
> 
> cheers
> stefan
> 
>>
>> Thanks.
>>
>>
>>
>>
>> JavaJ wrote:
>> >
>> > Given the following node types:
>> >
>> > [cm:myAppContainer] > nt:base,mix:referenceable,mix:versionable
>> > + cm:myApp (cm:myApp) = cm:myApp multiple version
>> >
>> > [cm:myApp] > nt:base,mix:referenceable,mix:versionable
>> > - cm:size (long) mandatory
>> > - cm:rules mandatory
>> > - cm:locale mandatory
>> > - cm:address mandatory
>> >
>> > I'm getting an error when I try to add a "myApp" child node to
>> > "myAppContainer".
>> >
>> > For example:
>> >
>> > // get the "myAppContainer" node
>> > Node container = rootNode.get("/nodes/myAppContainer");
>> >
>> > // get the child node definitions to make sure it contains "myApp"
>> child
>> > node definition
>> > NodeDefinition[] defs =
>> > container.getPrimaryNodeType().getDeclaredChildNodeDefinitions();
>> >
>> > // add a new "myApp" node
>> > newNode = container.addNode("myNewAppNode", "cm:myApp");
>> >
>> > I get this error on this call:
>> >
>> > javax.jcr.nodetype.ConstraintViolationException: no definition found in
>> > parent node's node type for new node:
>> > no matching child node definition found for {}myNewAppNode:
>> >
>> > Is there something I'm doing wrong???
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Problem-adding-a-child-node-tf2065497.html#a12463572
>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-adding-a-child-node-tf2065497.html#a12471478
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Mime
View raw message