You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Frederic BOY <fr...@gmail.com> on 2008/05/27 16:15:47 UTC

importXML() fails with a ConstraintViolationException

Hi,

 

Here's my problem: 

 

I have a repository organized as follows:

root (jcr:system)

|-- Video (mc:ItemType)

|      |-- Item1 (mc:VideoItem)

|      |-- Item2 (mc:VideoItem)

|           .

|      |-- ItemN (mc:VideoItem)

|-- Audio (mc:ItemType)

|      |-- Item1 (mc:AudioItem)

|      |-- Item2 (mc:AudioItem)

|           .

|      |-- ItemN (mc:AudioItem)

|-- Template (mc:ItemType)

|      |-- .

 

   

In order to backup all my data, I call the following methods:

      session.exportSystemView("/Video", videoOut, true, false);

      session.exportSystemView("/Audio", audioOut, true, false);

            session.exportSystemView("/Template", templateOut, true, false);

 

(It works like a charm: my 3 xml files are created properly)

 

And on the other end, I try to import data by calling:

            session.importXML("/Video", videoIn,
ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);

      session.importXML("/Audio", audioIn,
ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);

      session.importXML("/Template", templateIn,
ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);

 

On import, though my node types are correctly registered, I would get the
following exception:

ConstraintViolationException: no matching child node definition found for
child node {}Video.

 

Here is my CND file:

<nt = 'http://www.jcp.org/jcr/nt/1.0'>

<mix = 'http://www.jcp.org/jcr/mix/1.0'>

<mc = 'http://www.v-4-x.com/mediacenter'>

 [mc:AbstractMediaItem] > nt:base, mix:referenceable

 - mc:Title (string) primary

 - mc:Category (string)

 - mc:Tags (string) multiple

 - mc:Description (string)

 - mc:Comment (string)

 - mc:Source (string)

 - mc:Author (string)

 [mc:VideoItem] > mc:AbstractMediaItem

 + mc:WaveForm (mc:Resource)

 + mc:Thumbnail (mc:VideoThumbnail) multiple

 [mc:AudioItem] > mc:AbstractMediaItem

 + mc:WaveForm (mc:Resource)

 [mc:TemplateItem] > mc:AbstractMediaItem

 [mc:ItemType]

 + * (mc:AbstractMediaItem)

 

 

I must have missed something .

Could someone please help me? I'm kinda stuck here

 

Thanks in advance !

 

Frederic Boy


Re: importXML() fails with a ConstraintViolationException

Posted by Janne Jalkanen <ja...@ecyrd.com>.
On 30 Sep 2009, at 12:16, Alexander Klimetschek wrote:

> On Wed, Sep 30, 2009 at 07:12, freak182 <em...@gmail.com>  
> wrote:
>>  javax.jcr.nodetype.ConstraintViolationException: no matching  
>> property
>> definition found for {http://www.jcp.org/jcr/1.0}baseVersion
>>
>> ...how can i solve this?
>
> Import of versions is not supported at the moment.

Shouldn't jcr:baseVersion be in that case on the ignored properties  
list for import?

/Janne

Re: importXML() fails with a ConstraintViolationException

Posted by Alexander Klimetschek <ak...@day.com>.
On Wed, Sep 30, 2009 at 07:12, freak182 <em...@gmail.com> wrote:
> I export my repository using exportDocument view and path is
> /photo/upload/test/ (plus the binary and contain versions) and it work fine.
> Now when i importXML
>
> session.importXML("/", file,
> ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
>
>  i got this error:
>
>  javax.jcr.nodetype.ConstraintViolationException: no matching property
> definition found for {http://www.jcp.org/jcr/1.0}baseVersion
>
> ...how can i solve this?

Import of versions is not supported at the moment.

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Re: importXML() fails with a ConstraintViolationException

Posted by freak182 <em...@gmail.com>.
Hello,

I export my repository using exportDocument view and path is
/photo/upload/test/ (plus the binary and contain versions) and it work fine.
Now when i importXML

session.importXML("/", file,
ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);

 i got this error:

 javax.jcr.nodetype.ConstraintViolationException: no matching property
definition found for {http://www.jcp.org/jcr/1.0}baseVersion

...how can i solve this?

thanks a lot.
cheers.


Jukka Zitting wrote:
> 
> Hi,
> 
> On Tue, May 27, 2008 at 5:15 PM, Frederic BOY <fr...@gmail.com>
> wrote:
>> session.exportSystemView("/Video", videoOut, true, false);
>> [...]
>> session.importXML("/Video", videoIn,
>>     ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
>> [...]
>> ConstraintViolationException: no matching child node definition found for
>> child node {}Video.
> 
> You're trying to import the "Video" subtree under an existing "Video"
> node. Try:
> 
>     session.importXML("/", videoIn,
>         ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
> 
> Also, you might want to consider adding a "/content" top-level node
> under which you'd place your "Video", "Audio", and "Template" subtrees
> (and any other content you may have). This way you could backup your
> entire content in a single operation.
> 
> BR,
> 
> Jukka Zitting
> 
> 

-- 
View this message in context: http://www.nabble.com/importXML%28%29-fails-with-a-ConstraintViolationException-tp17491487p25675120.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: importXML() fails with a ConstraintViolationException

Posted by Tobias Bocanegra <to...@day.com>.
On 5/28/08, Bertrand Delacretaz <bd...@apache.org> wrote:
> On Wed, May 28, 2008 at 10:13 AM, Alexander Klimetschek
>  <ak...@day.com> wrote:
>
>  > ...Jackrabbit has a limitation when you have many child nodes (>
>  > 1000) under one node - it will be quite slow then...
>
>  I thought this was ten thousand, not thousand?
please note: there is no actual limitation for child nodes. you could
create millions, if you like. it just does not scale well.
for best performance keep it below 1000, for good manageability with a
jcr-browser, i would keep it below 10'000.

regards, toby

Re: importXML() fails with a ConstraintViolationException

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Wed, May 28, 2008 at 10:13 AM, Alexander Klimetschek
<ak...@day.com> wrote:

> ...Jackrabbit has a limitation when you have many child nodes (>
> 1000) under one node - it will be quite slow then...

I thought this was ten thousand, not thousand?

-Bertrand

Re: importXML() fails with a ConstraintViolationException

Posted by Alexander Klimetschek <ak...@day.com>.
On Wed, May 28, 2008 at 12:19 PM, Tobias Bocanegra
<to...@day.com> wrote:
> On 5/28/08, Stefan Guggisberg <st...@day.com> wrote:
>> i don't know how you determined that limit but it's IMO rather defensive.
>>  tests that i've run a while ago showed that there's no significant
>>  performance impact with up to 10k child nodes (which is quite a lot).
> ok then :-) keep it below 10k :-)

Oh, sorry, I was just giving a pessimistic guestimated limit when I
said 1000. Good to know that 10k is also working fine.

Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Re: importXML() fails with a ConstraintViolationException

Posted by Tobias Bocanegra <to...@day.com>.
On 5/28/08, Stefan Guggisberg <st...@day.com> wrote:
> On Wed, May 28, 2008 at 10:13 AM, Alexander Klimetschek
>  <ak...@day.com> wrote:
>
> > Hi Frederic,
>  >
>  > in general using import/export XML (especially for larger XML chunks)
>  > is not the most efficient way to work with JCR. Using the API directly
>  > in combination with an effective content model is the way to go. An
>  > effective content model tries to reduce the number of nodes (XML
>  > imports tend to create lots of nodes with a single property at the
>  > leaf) and has a high properties/nodes ratio: something around 10 is
>  > good (ie. 10 times more properties than nodes). This is especially
>  > true if you use a bundle persistence manager (which you should ;-)),
>  > because it reads/writes bundles that consist of a node and all its
>  > properties (except for larger binary properties that will go into the
>  > DataStore, if configured).
>  >
>  > Having flat hierarchies ("repository in width") is not efficient,
>  > since Jackrabbit has a limitation when you have many child nodes (>
>  > 1000) under one node
>
>
> i don't know how you determined that limit but it's IMO rather defensive.
>  tests that i've run a while ago showed that there's no significant
>  performance impact with up to 10k child nodes (which is quite a lot).
ok then :-) keep it below 10k :-)

--
toby

Re: importXML() fails with a ConstraintViolationException

Posted by Stefan Guggisberg <st...@day.com>.
On Wed, May 28, 2008 at 10:13 AM, Alexander Klimetschek
<ak...@day.com> wrote:
> Hi Frederic,
>
> in general using import/export XML (especially for larger XML chunks)
> is not the most efficient way to work with JCR. Using the API directly
> in combination with an effective content model is the way to go. An
> effective content model tries to reduce the number of nodes (XML
> imports tend to create lots of nodes with a single property at the
> leaf) and has a high properties/nodes ratio: something around 10 is
> good (ie. 10 times more properties than nodes). This is especially
> true if you use a bundle persistence manager (which you should ;-)),
> because it reads/writes bundles that consist of a node and all its
> properties (except for larger binary properties that will go into the
> DataStore, if configured).
>
> Having flat hierarchies ("repository in width") is not efficient,
> since Jackrabbit has a limitation when you have many child nodes (>
> 1000) under one node

i don't know how you determined that limit but it's IMO rather defensive.
tests that i've run a while ago showed that there's no significant
performance impact with up to 10k child nodes (which is quite a lot).

cheers
stefan

>  - it will be quite slow then. In favor of human
> explorability one should avoid that anyway, since it is easier when
> the content is structured, eg. by date (/2008/april/*), so that only a
> few children are visible at each level.
>
> Hope this helps,
> Alex
>
> On Tue, May 27, 2008 at 6:07 PM, Frederic BOY <fr...@gmail.com> wrote:
>> Thanks Jukka, you just saved my life here.
>>
>> I would like to ask another question, which somehow is linked:
>> How can I speed up access to my content repository, seeing how it's
>> organized? (cf CND below)
>>
>> I've read that a repository "in depth" allows better performances (on search
>> queries) than a rep in width. Is that true? Are XPATH queries faster than
>> SQL for example?  Is there any trick I could give a try?
>>
>> Again, thanks a million.
>>
>>
>> Fred
>>
>> -----Message d'origine-----
>> De : Jukka Zitting [mailto:jukka.zitting@gmail.com]
>> Envoyé : mardi 27 mai 2008 16:59
>> À : users@jackrabbit.apache.org
>> Objet : Re: importXML() fails with a ConstraintViolationException
>>
>> Hi,
>>
>> On Tue, May 27, 2008 at 5:15 PM, Frederic BOY <fr...@gmail.com>
>> wrote:
>>> session.exportSystemView("/Video", videoOut, true, false);
>>> [...]
>>> session.importXML("/Video", videoIn,
>>>     ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
>>> [...]
>>> ConstraintViolationException: no matching child node definition found for
>>> child node {}Video.
>>
>> You're trying to import the "Video" subtree under an existing "Video" node.
>> Try:
>>
>>    session.importXML("/", videoIn,
>>        ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
>>
>> Also, you might want to consider adding a "/content" top-level node
>> under which you'd place your "Video", "Audio", and "Template" subtrees
>> (and any other content you may have). This way you could backup your
>> entire content in a single operation.
>>
>> BR,
>>
>> Jukka Zitting
>>
>>
>
>
>
> --
> Alexander Klimetschek
> alexander.klimetschek@day.com
>
>>> Day JCR Cup 08 | Win a MacBook Pro: http://dev.day.com/ <<
>
> ----------------------------< alexander.klimetschek@day.com >----------
> Alexander Klimetschek, Day Management AG, Barfuesserplatz 6,
> CH - 4001 Basel, T +41 61 226 55 31, M +49 151 15 77 20 56
> ---------------------------------------< http://www.day.com >-----------------
>
> Xing: http://www.xing.com/go/invite/3268380.32d2d4
> LinkedIn: http://www.linkedin.com/in/klimetschek
> Blog: http://weblogs.goshaky.com/weblogs/alexkli/
>

Re: importXML() fails with a ConstraintViolationException

Posted by Stefan Guggisberg <st...@day.com>.
On Wed, May 28, 2008 at 2:16 PM, Florian Holeczek <fl...@holeczek.de> wrote:
> Hallo Alexander,
>
>> An effective content model tries to reduce the number of nodes (XML
>> imports tend to create lots of nodes with a single property at the
>> leaf) and has a high properties/nodes ratio: something around 10 is
>> good (ie. 10 times more properties than nodes). This is especially
>> true if you use a bundle persistence manager (which you should ;-)),
>> because it reads/writes bundles that consist of a node and all its
>> properties (except for larger binary properties that will go into
>> the DataStore, if configured).
>> Having flat hierarchies ("repository in width") is not efficient,
>> since Jackrabbit has a limitation when you have many child nodes (>
>> 1000) under one node - it will be quite slow then. In favor of human
>> explorability one should avoid that anyway, since it is easier when
>> the content is structured, eg. by date (/2008/april/*), so that only a
>> few children are visible at each level.
>
> Thanks for pointing this out!
>
> Is this documented somewhere or just internal developer knowledge?

it has been discussed on the list repeatedly.

>
> Is it for reasons of the JCR concept / API or due to restrictions of
> the Jackrabbit implementation?

there's no hard-coded limit for the # of child nodes per node. the current
design is optimized for small to medium sized child node sets, i.e. up to
~10k child nodes per node. really large child node sets negatively affect
write performance (in the current design).

cheers
stefan

>
> Regards,
>  Florian
>

Re: importXML() fails with a ConstraintViolationException

Posted by Florian Holeczek <fl...@holeczek.de>.
Hallo Alexander,

> An effective content model tries to reduce the number of nodes (XML
> imports tend to create lots of nodes with a single property at the
> leaf) and has a high properties/nodes ratio: something around 10 is
> good (ie. 10 times more properties than nodes). This is especially
> true if you use a bundle persistence manager (which you should ;-)),
> because it reads/writes bundles that consist of a node and all its
> properties (except for larger binary properties that will go into
> the DataStore, if configured).
> Having flat hierarchies ("repository in width") is not efficient,
> since Jackrabbit has a limitation when you have many child nodes (>
> 1000) under one node - it will be quite slow then. In favor of human
> explorability one should avoid that anyway, since it is easier when
> the content is structured, eg. by date (/2008/april/*), so that only a
> few children are visible at each level.

Thanks for pointing this out!

Is this documented somewhere or just internal developer knowledge?

Is it for reasons of the JCR concept / API or due to restrictions of
the Jackrabbit implementation?

Regards,
 Florian

Re: importXML() fails with a ConstraintViolationException

Posted by Alexander Klimetschek <ak...@day.com>.
Hi Frederic,

in general using import/export XML (especially for larger XML chunks)
is not the most efficient way to work with JCR. Using the API directly
in combination with an effective content model is the way to go. An
effective content model tries to reduce the number of nodes (XML
imports tend to create lots of nodes with a single property at the
leaf) and has a high properties/nodes ratio: something around 10 is
good (ie. 10 times more properties than nodes). This is especially
true if you use a bundle persistence manager (which you should ;-)),
because it reads/writes bundles that consist of a node and all its
properties (except for larger binary properties that will go into the
DataStore, if configured).

Having flat hierarchies ("repository in width") is not efficient,
since Jackrabbit has a limitation when you have many child nodes (>
1000) under one node - it will be quite slow then. In favor of human
explorability one should avoid that anyway, since it is easier when
the content is structured, eg. by date (/2008/april/*), so that only a
few children are visible at each level.

Hope this helps,
Alex

On Tue, May 27, 2008 at 6:07 PM, Frederic BOY <fr...@gmail.com> wrote:
> Thanks Jukka, you just saved my life here.
>
> I would like to ask another question, which somehow is linked:
> How can I speed up access to my content repository, seeing how it's
> organized? (cf CND below)
>
> I've read that a repository "in depth" allows better performances (on search
> queries) than a rep in width. Is that true? Are XPATH queries faster than
> SQL for example?  Is there any trick I could give a try?
>
> Again, thanks a million.
>
>
> Fred
>
> -----Message d'origine-----
> De : Jukka Zitting [mailto:jukka.zitting@gmail.com]
> Envoyé : mardi 27 mai 2008 16:59
> À : users@jackrabbit.apache.org
> Objet : Re: importXML() fails with a ConstraintViolationException
>
> Hi,
>
> On Tue, May 27, 2008 at 5:15 PM, Frederic BOY <fr...@gmail.com>
> wrote:
>> session.exportSystemView("/Video", videoOut, true, false);
>> [...]
>> session.importXML("/Video", videoIn,
>>     ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
>> [...]
>> ConstraintViolationException: no matching child node definition found for
>> child node {}Video.
>
> You're trying to import the "Video" subtree under an existing "Video" node.
> Try:
>
>    session.importXML("/", videoIn,
>        ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
>
> Also, you might want to consider adding a "/content" top-level node
> under which you'd place your "Video", "Audio", and "Template" subtrees
> (and any other content you may have). This way you could backup your
> entire content in a single operation.
>
> BR,
>
> Jukka Zitting
>
>



-- 
Alexander Klimetschek
alexander.klimetschek@day.com

>> Day JCR Cup 08 | Win a MacBook Pro: http://dev.day.com/ <<

----------------------------< alexander.klimetschek@day.com >----------
Alexander Klimetschek, Day Management AG, Barfuesserplatz 6,
CH - 4001 Basel, T +41 61 226 55 31, M +49 151 15 77 20 56
---------------------------------------< http://www.day.com >-----------------

Xing: http://www.xing.com/go/invite/3268380.32d2d4
LinkedIn: http://www.linkedin.com/in/klimetschek
Blog: http://weblogs.goshaky.com/weblogs/alexkli/

RE: importXML() fails with a ConstraintViolationException

Posted by Frederic BOY <fr...@gmail.com>.
Thanks Jukka, you just saved my life here.

I would like to ask another question, which somehow is linked:
How can I speed up access to my content repository, seeing how it's
organized? (cf CND below)

I've read that a repository "in depth" allows better performances (on search
queries) than a rep in width. Is that true? Are XPATH queries faster than
SQL for example?  Is there any trick I could give a try?

Again, thanks a million.


Fred

-----Message d'origine-----
De : Jukka Zitting [mailto:jukka.zitting@gmail.com] 
Envoyé : mardi 27 mai 2008 16:59
À : users@jackrabbit.apache.org
Objet : Re: importXML() fails with a ConstraintViolationException

Hi,

On Tue, May 27, 2008 at 5:15 PM, Frederic BOY <fr...@gmail.com>
wrote:
> session.exportSystemView("/Video", videoOut, true, false);
> [...]
> session.importXML("/Video", videoIn,
>     ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
> [...]
> ConstraintViolationException: no matching child node definition found for
> child node {}Video.

You're trying to import the "Video" subtree under an existing "Video" node.
Try:

    session.importXML("/", videoIn,
        ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);

Also, you might want to consider adding a "/content" top-level node
under which you'd place your "Video", "Audio", and "Template" subtrees
(and any other content you may have). This way you could backup your
entire content in a single operation.

BR,

Jukka Zitting


Re: importXML() fails with a ConstraintViolationException

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Tue, May 27, 2008 at 5:15 PM, Frederic BOY <fr...@gmail.com> wrote:
> session.exportSystemView("/Video", videoOut, true, false);
> [...]
> session.importXML("/Video", videoIn,
>     ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
> [...]
> ConstraintViolationException: no matching child node definition found for
> child node {}Video.

You're trying to import the "Video" subtree under an existing "Video" node. Try:

    session.importXML("/", videoIn,
        ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);

Also, you might want to consider adding a "/content" top-level node
under which you'd place your "Video", "Audio", and "Template" subtrees
(and any other content you may have). This way you could backup your
entire content in a single operation.

BR,

Jukka Zitting