You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by John Tranier <jo...@fylab.com> on 2010/04/08 15:43:53 UTC

Jackrabbit 1.6 and DavEx ?

Hi all,

I have a Jackrabbit repository 1.6 that is currently embedded into our 
web application (deployment model 1).
We need now to externalize the repository (deployment model 3), and we 
do not have time yet to upgrade to the version 2.0.

So my question is : is it possible to have a DavEx remote connection to 
a repository with the API 1.6 ?
I tried to figure out by myself by browsing the docs and the list, but I 
couldn't find this information. I just saw the package spi2davex that 
gives me some hope.

If it's possible to do it, I would be glad to have a snippet of code to 
establish the connection. I've found it for the version 2.0 but I guess 
the Utils class used is proper to 2.0.

Thank you !
John

Re: Jackrabbit 1.6 and DavEx ?

Posted by Angela Schreiber <an...@day.com>.
hi john

> I just discovered something that looks like a strange behaviour to me
> and I would like to check whether it is expected or not.
> With jcr2spi the cache seems to be handled per session.
> 
> Here is a sequence to illustrate it :
> 1. Create jcrSession1
> 2. Create jcrSession2
> 3. Add a node n with jcrSession1

and save(), right?

> 4. ItemExists(n) with jcrSession2 returns false
> 5. Add a node n with jcrSession2 ==> Exception ItemExists
> 
> If I swap point 2. and 3. (i.e. I create jcrSession2 after adding the
> node n with jcrSession1) everything works fine.
> 
> Is there a reason I don't know to handle the cache at the session
> level and not at the repository proxy level ?

we made some optimizations regarding the caching behavior in the
past (i don't recall for which version exactly though) in order
to minimize the number of round trips to the SPI layer, which
possibly includes expensive network roundtrips. one that might be 
related to the problem described is a flag with childnodeentries that 
defines if the list is complete at the point of being populated
-> refresh is required in order to force a reload of the list.

> And beside that, is there a way to invalidate the cache of a session
> (apart from closing and reopening a session) ?

Session.refresh() and Item.refresh() should do the trick. it's
the JCR way to force reloading of the status visible to a particular
session.

one more thing was the CacheBehavior configuration flag:

with jcr2spi running in CacheBehavior.OBSERVATION mode the
refresh call is a nop as in this configuration all changes from
the SPI should be automatically update the existing clients (jcr2spi 
Sessions)... i didn't try this one for a while, though.

with jcr2spi running in CacheBehavior.INVALIDATION (default)
you may need an explicit/manual refresh call to get the latest
state of the persistent layer (SPI implementation).

hope that helps
angela

Re: Jackrabbit 1.6 and DavEx ?

Posted by John Tranier <jo...@fylab.com>.
Hi !

Good news : I've migrated to 2.1.0 and the problem I had with move
disappeared :-)

I just discovered something that looks like a strange behaviour to me
and I would like to check whether it is expected or not.
With jcr2spi the cache seems to be handled per session.

Here is a sequence to illustrate it :
1. Create jcrSession1
2. Create jcrSession2
3. Add a node n with jcrSession1
4. ItemExists(n) with jcrSession2 returns false
5. Add a node n with jcrSession2 ==> Exception ItemExists

If I swap point 2. and 3. (i.e. I create jcrSession2 after adding the
node n with jcrSession1) everything works fine.

Is there a reason I don't know to handle the cache at the session
level and not at the repository proxy level ?
And beside that, is there a way to invalidate the cache of a session
(apart from closing and reopening a session) ?

Thanks for your help
John



2010/5/4 John Tranier <jo...@fylab.com>:
> Hi Angela,
> I guess it's a better option to upgrade to 2.1 for accessing the repository
> in WebDav.
> I will try that.
> Thank you for your answers.
> John
>
> 2010/5/4 Angela Schreiber <an...@day.com>
>>
>> hi john
>>
>>> Concerning the problem 2 (move), here is an example :
>>>
>>> jcrSession.move(
>>>            fichierNode.path,
>>>            fichierNode.parent.path + '/' + 'newName')
>>>
>>> fichierNode.setProperty( JcrConstants.ELIOT_DATE_MODIFICATION,
>>> Calendar.getInstance() )
>>>
>>> jcrSession.save() => throws javax.jcr.PathNotFoundException: <old path>
>>>
>>> The problem is solved when I update the property before the move.
>>
>> depending on the nature of your "fichierNode" this
>> could be the same as JCR-2472, which has been fixed for 2.1
>>
>>> For the problem 1, I give you a short description followed by my concrete
>>> code.
>>> I have 2 mixin types, let's say A and B, with B that inherits A.
>>> When I add the type A, and then the type B I get an exception
>>> javax.jcr.nodetype.ConstraintViolationException:
>>> no matching property definition found for ...
>>> It works when I save the session after adding the type A.
>>
>>>    *jcrSession.save() => Without that save it works with the Repository
>>> from core, but not with a webdav connection*
>>
>> not sure, but the reason for this might be that in jcr2spi mixin types
>> are only effective on a given node *after* save() [1].
>> in this part jcr2spi works different than jackrabbit-core since
>> jcr2spi doesn't not have the ability to create autocreated items
>> such as e.g. defined by mix:referenceable and mix:versionable and
>> may not be able to detect conflicts arising from adding the mixin
>> type. this is therefore delegated to the SPI implementation.
>>
>> regards
>> angela
>>
>> [1] see section "10.10 Node Type Assignment" of the specification
>>    and the following quote from the javadoc of Node#addMixin:
>>    "Semantically, the new node type may take effect immediately,
>>     on dispatch or on persist."
>>
>>
>>
>
>

Re: Jackrabbit 1.6 and DavEx ?

Posted by John Tranier <jo...@fylab.com>.
Hi !

Good news : I've migrated to 2.1.0 and the problem I had with move
disappeared :-)

I just discovered something that looks like a strange behaviour to me
and I would like to check whether it is expected or not.
With jcr2spi the cache seems to be handled per session.

Here is a sequence to illustrate it :
1. Create jcrSession1
2. Create jcrSession2
3. Add a node n with jcrSession1
4. ItemExists(n) with jcrSession2 returns false
5. Add a node n with jcrSession2 ==> Exception ItemExists

If I swap point 2. and 3. (i.e. I create jcrSession2 after adding the
node n with jcrSession1) everything works fine.

Is there a reason I don't know to handle the cache at the session
level and not at the repository proxy level ?
And beside that, is there a way to invalidate the cache of a session
(apart from closing and reopening a session) ?

Thanks for your help
John



2010/5/4 John Tranier <jo...@fylab.com>:
> Hi Angela,
> I guess it's a better option to upgrade to 2.1 for accessing the repository
> in WebDav.
> I will try that.
> Thank you for your answers.
> John
>
> 2010/5/4 Angela Schreiber <an...@day.com>
>>
>> hi john
>>
>>> Concerning the problem 2 (move), here is an example :
>>>
>>> jcrSession.move(
>>>            fichierNode.path,
>>>            fichierNode.parent.path + '/' + 'newName')
>>>
>>> fichierNode.setProperty( JcrConstants.ELIOT_DATE_MODIFICATION,
>>> Calendar.getInstance() )
>>>
>>> jcrSession.save() => throws javax.jcr.PathNotFoundException: <old path>
>>>
>>> The problem is solved when I update the property before the move.
>>
>> depending on the nature of your "fichierNode" this
>> could be the same as JCR-2472, which has been fixed for 2.1
>>
>>> For the problem 1, I give you a short description followed by my concrete
>>> code.
>>> I have 2 mixin types, let's say A and B, with B that inherits A.
>>> When I add the type A, and then the type B I get an exception
>>> javax.jcr.nodetype.ConstraintViolationException:
>>> no matching property definition found for ...
>>> It works when I save the session after adding the type A.
>>
>>>    *jcrSession.save() => Without that save it works with the Repository
>>> from core, but not with a webdav connection*
>>
>> not sure, but the reason for this might be that in jcr2spi mixin types
>> are only effective on a given node *after* save() [1].
>> in this part jcr2spi works different than jackrabbit-core since
>> jcr2spi doesn't not have the ability to create autocreated items
>> such as e.g. defined by mix:referenceable and mix:versionable and
>> may not be able to detect conflicts arising from adding the mixin
>> type. this is therefore delegated to the SPI implementation.
>>
>> regards
>> angela
>>
>> [1] see section "10.10 Node Type Assignment" of the specification
>>    and the following quote from the javadoc of Node#addMixin:
>>    "Semantically, the new node type may take effect immediately,
>>     on dispatch or on persist."
>>
>>
>>
>
>

Re: Jackrabbit 1.6 and DavEx ?

Posted by John Tranier <jo...@fylab.com>.
Hi Angela,

I guess it's a better option to upgrade to 2.1 for accessing the repository
in WebDav.
I will try that.
Thank you for your answers.

John


2010/5/4 Angela Schreiber <an...@day.com>

> hi john
>
>
>  Concerning the problem 2 (move), here is an example :
>>
>> jcrSession.move(
>>            fichierNode.path,
>>            fichierNode.parent.path + '/' + 'newName')
>>
>> fichierNode.setProperty( JcrConstants.ELIOT_DATE_MODIFICATION,
>> Calendar.getInstance() )
>>
>> jcrSession.save() => throws javax.jcr.PathNotFoundException: <old path>
>>
>> The problem is solved when I update the property before the move.
>>
>
> depending on the nature of your "fichierNode" this
> could be the same as JCR-2472, which has been fixed for 2.1
>
>
>  For the problem 1, I give you a short description followed by my concrete
>> code.
>> I have 2 mixin types, let's say A and B, with B that inherits A.
>> When I add the type A, and then the type B I get an exception
>> javax.jcr.nodetype.ConstraintViolationException:
>> no matching property definition found for ...
>> It works when I save the session after adding the type A.
>>
>
>     *jcrSession.save() => Without that save it works with the Repository
>> from core, but not with a webdav connection*
>>
>
> not sure, but the reason for this might be that in jcr2spi mixin types
> are only effective on a given node *after* save() [1].
> in this part jcr2spi works different than jackrabbit-core since
> jcr2spi doesn't not have the ability to create autocreated items
> such as e.g. defined by mix:referenceable and mix:versionable and
> may not be able to detect conflicts arising from adding the mixin
> type. this is therefore delegated to the SPI implementation.
>
> regards
> angela
>
> [1] see section "10.10 Node Type Assignment" of the specification
>    and the following quote from the javadoc of Node#addMixin:
>    "Semantically, the new node type may take effect immediately,
>     on dispatch or on persist."
>
>
>
>

Re: Jackrabbit 1.6 and DavEx ?

Posted by Angela Schreiber <an...@day.com>.
hi john

> Concerning the problem 2 (move), here is an example :
> 
> jcrSession.move(
>             fichierNode.path,
>             fichierNode.parent.path + '/' + 'newName')
> 
> fichierNode.setProperty( JcrConstants.ELIOT_DATE_MODIFICATION,
> Calendar.getInstance() )
> 
> jcrSession.save() => throws javax.jcr.PathNotFoundException: <old path>
> 
> The problem is solved when I update the property before the move.

depending on the nature of your "fichierNode" this
could be the same as JCR-2472, which has been fixed for 2.1

> For the problem 1, I give you a short description followed by my concrete
> code.
> I have 2 mixin types, let's say A and B, with B that inherits A.
> When I add the type A, and then the type B I get an exception
> javax.jcr.nodetype.ConstraintViolationException:
> no matching property definition found for ...
> It works when I save the session after adding the type A.

>     *jcrSession.save() => Without that save it works with the Repository
> from core, but not with a webdav connection*

not sure, but the reason for this might be that in jcr2spi mixin types
are only effective on a given node *after* save() [1].
in this part jcr2spi works different than jackrabbit-core since
jcr2spi doesn't not have the ability to create autocreated items
such as e.g. defined by mix:referenceable and mix:versionable and
may not be able to detect conflicts arising from adding the mixin
type. this is therefore delegated to the SPI implementation.

regards
angela

[1] see section "10.10 Node Type Assignment" of the specification
     and the following quote from the javadoc of Node#addMixin:
     "Semantically, the new node type may take effect immediately,
      on dispatch or on persist."




Re: Jackrabbit 1.6 and DavEx ?

Posted by John Tranier <jo...@fylab.com>.
Thanks again for your quick reply.

Concerning the problem 2 (move), here is an example :

jcrSession.move(
            fichierNode.path,
            fichierNode.parent.path + '/' + 'newName')

fichierNode.setProperty( JcrConstants.ELIOT_DATE_MODIFICATION,
Calendar.getInstance() )

jcrSession.save() => throws javax.jcr.PathNotFoundException: <old path>

The problem is solved when I update the property before the move.


For the problem 1, I give you a short description followed by my concrete
code.
I have 2 mixin types, let's say A and B, with B that inherits A.
When I add the type A, and then the type B I get an exception
javax.jcr.nodetype.ConstraintViolationException:
no matching property definition found for ...
It works when I save the session after adding the type A.

Here is the relevant part of my CND file:
<eliot = 'http://www.fylab.com/eliot'> [eliot:item] mixin -
eliot:proprietaire_id (string) mandatory - eliot:auteurs_ids (string)
mandatory multiple - eliot:item_description (string) -
eliot:date_modification (date) mandatory [eliot:item_partage] > eliot:item
mixin - eliot:consultation_autorites_ids (string) mandatory multiple -
eliot:modification_autorites_ids (string) mandatory multiple

And my code :
// Création du noeud racine de l'espace de partage de l'organisation
    Node partageNode =
    organisationNode.addNode(

 JcrSystemNodeDefinitions.getInfoEspacePartage(organisationId).nom,
            JcrConstants.NT_FOLDER
    )
    partageNode.addMixin(JcrConstants.ELIOT_RACINE_ESPACE_PARTAGE)
    partageNode.addMixin(JcrConstants.MIX_REFERENCEABLE)
    partageNode.addMixin(JcrConstants.ELIOT_ITEM)

    // Propriétaire
    partageNode.setProperty(
            JcrConstants.ELIOT_PROPRIETAIRE_ID,
            JcrConstants.ELIOT_ADMIN_ID
    )

    // Auteurs
    partageNode.setProperty(
            JcrConstants.ELIOT_AUTEURS_IDS,
            (String[])[].toArray()
    )

    // Description
    partageNode.setProperty(
            JcrConstants.ELIOT_ITEM_DESCRIPTION,
            JcrSystemNodeDefinitions.getInfoEspacePartage(
                    organisationId).description
    )

    // Date modification
    partageNode.setProperty(
            JcrConstants.ELIOT_DATE_MODIFICATION,
            Calendar.getInstance()
    )

    *jcrSession.save() => Without that save it works with the Repository
from core, but not with a webdav connection*

    // Initialise les attributs de partage
    partageNode.addMixin(JcrConstants.ELIOT_ITEM_PARTAGE)
    partageNode.setProperty(
            JcrConstants.ELIOT_CONSULTATION_AUTORITES_IDS,
            (String[]) []  // Liste vide  //Todo: Tout le monde doit pouvoir
consulter
    )
    partageNode.setProperty(
            JcrConstants.ELIOT_MODIFICATION_AUTORITES_IDS,
            (String[]) []  // Liste vide //Todo: Initialiser avec les
groupes qui ont le droit d'écriture par défaut
    )

    jcrSession.save()

The concrete exception I get without the intermediary save is:
javax.jcr.nodetype.ConstraintViolationException: no matching property
definition found for {http://www.fylab.com/eliot}proprietaire_id
<http://www.google.com/url?sa=D&q=http%3A%2F%2Fwww.fylab.com%2Feliot%7Dproprietaire_id>

John

2010/4/29 Angela Schreiber <an...@day.com>

> hi john
>
>
>  Unfortunately, many of my integration tests are not passing anymore.
>> After some investigations, I could figure out these 2 issues :
>> 1) DavEx requires the session to be saved more frequently to avoid
>> exception
>> on type constraints (in particular, I have a mixin type that inherits from
>> another - When I need to add both types to a node, a session.save() in
>> between is necessary).
>>
>
> can you provide a test that illustrates the problem.
> from the description above i can't tell if this is bug or not.
>
>
>  2) session.move doesn't seem to be handled properly : after a move, any
>> operation on the moved node within the current session leads to a
>> PathNotFoundException (with the old path).
>>
>
> there were a couple of issues fixed for version 2.1, including
> some move problems... again... having a simple test illustrating
> the error would be useful to find out if this is a known/fixed
> problem or not.
>
>
>  I wonder if those are known issues? And if there is a solution? Maybe it
>> is
>> different in version 2.0.0 (I'm using 1.6.0).
>>
>
> see above.
>
>
>  I saw on jira the issue JCR-2540 that says : "all TCK tests including move
>> or reorder fail in the setup jcr2spi - spi2dav(ex) - jcr-server."
>> It could be my problem.
>>
>
> no. JCR-2540 is about observation only.
>
> regards
> angela
>

Re: Jackrabbit 1.6 and DavEx ?

Posted by Angela Schreiber <an...@day.com>.
hi john

> Unfortunately, many of my integration tests are not passing anymore.
> After some investigations, I could figure out these 2 issues :
> 1) DavEx requires the session to be saved more frequently to avoid exception
> on type constraints (in particular, I have a mixin type that inherits from
> another - When I need to add both types to a node, a session.save() in
> between is necessary).

can you provide a test that illustrates the problem.
from the description above i can't tell if this is bug or not.

> 2) session.move doesn't seem to be handled properly : after a move, any
> operation on the moved node within the current session leads to a
> PathNotFoundException (with the old path).

there were a couple of issues fixed for version 2.1, including
some move problems... again... having a simple test illustrating
the error would be useful to find out if this is a known/fixed
problem or not.

> I wonder if those are known issues? And if there is a solution? Maybe it is
> different in version 2.0.0 (I'm using 1.6.0).

see above.

> I saw on jira the issue JCR-2540 that says : "all TCK tests including move
> or reorder fail in the setup jcr2spi - spi2dav(ex) - jcr-server."
> It could be my problem.

no. JCR-2540 is about observation only.

regards
angela

Re: Jackrabbit 1.6 and DavEx ?

Posted by John Tranier <jo...@fylab.com>.
Hi,

Thanks to the information provided by Angela I've been able to connect my
application to a repository through WebDAV (using the jackrabbit-webapp).

Unfortunately, many of my integration tests are not passing anymore.
After some investigations, I could figure out these 2 issues :
1) DavEx requires the session to be saved more frequently to avoid exception
on type constraints (in particular, I have a mixin type that inherits from
another - When I need to add both types to a node, a session.save() in
between is necessary).
2) session.move doesn't seem to be handled properly : after a move, any
operation on the moved node within the current session leads to a
PathNotFoundException (with the old path).

I wonder if those are known issues? And if there is a solution? Maybe it is
different in version 2.0.0 (I'm using 1.6.0).
I saw on jira the issue JCR-2540 that says : "all TCK tests including move
or reorder fail in the setup jcr2spi - spi2dav(ex) - jcr-server."
It could be my problem.

Best regards,
John



2010/4/10 John Tranier <jo...@fylab.com>

> Thanks a lot Angela for these very useful information :)
>
> John
>
> 2010/4/9 Angela Schreiber <an...@day.com>
>
> hi john
>>
>>
>>  So my question is : is it possible to have a DavEx remote connection to a
>>> repository with the API 1.6 ?
>>> I tried to figure out by myself by browsing the docs and the list, but I
>>> couldn't find this information. I just saw the package spi2davex that gives
>>> me some hope.
>>>
>>
>> when there is such a package it should be possible.
>> there are quite some issues fixed since then (-> see jira)
>> but apart from that it should work.
>>
>>
>>  If it's possible to do it, I would be glad to have a snippet of code to
>>> establish the connection. I've found it for the version 2.0 but I guess the
>>> Utils class used is proper to 2.0.
>>>
>>
>> you can easily create the connection by manually creating the
>> jcr2spi Repository instance. something like:
>>
>> String url = <your server url>;
>> final RepositoryService service = createService(url) // see below;
>> Repository repository = RepositoryImpl.create(new
>> AbstractRepositoryConfig() {
>>                    public RepositoryService getRepositoryService() {
>>                        return service;
>>                    }
>>                });
>>
>> private RepositoryService createService(String uri) throws
>> RepositoryException {
>>        BatchReadConfig brc = new BatchReadConfig() {
>>            public int getDepth(Path path, PathResolver resolver) throws
>> NamespaceException {
>>                return 4;
>>            }
>>        };
>>        return new RepositoryServiceImpl(uri, brc);
>>    }
>>
>> that code is copied from the test setup in spi2davex.
>> hope that helps
>> angela
>>
>>> Thank you !
>>> John
>>>
>>>
>>
>

Re: Jackrabbit 1.6 and DavEx ?

Posted by John Tranier <jo...@fylab.com>.
Thanks a lot Angela for these very useful information :)

John

2010/4/9 Angela Schreiber <an...@day.com>

> hi john
>
>
>  So my question is : is it possible to have a DavEx remote connection to a
>> repository with the API 1.6 ?
>> I tried to figure out by myself by browsing the docs and the list, but I
>> couldn't find this information. I just saw the package spi2davex that gives
>> me some hope.
>>
>
> when there is such a package it should be possible.
> there are quite some issues fixed since then (-> see jira)
> but apart from that it should work.
>
>
>  If it's possible to do it, I would be glad to have a snippet of code to
>> establish the connection. I've found it for the version 2.0 but I guess the
>> Utils class used is proper to 2.0.
>>
>
> you can easily create the connection by manually creating the
> jcr2spi Repository instance. something like:
>
> String url = <your server url>;
> final RepositoryService service = createService(url) // see below;
> Repository repository = RepositoryImpl.create(new
> AbstractRepositoryConfig() {
>                    public RepositoryService getRepositoryService() {
>                        return service;
>                    }
>                });
>
> private RepositoryService createService(String uri) throws
> RepositoryException {
>        BatchReadConfig brc = new BatchReadConfig() {
>            public int getDepth(Path path, PathResolver resolver) throws
> NamespaceException {
>                return 4;
>            }
>        };
>        return new RepositoryServiceImpl(uri, brc);
>    }
>
> that code is copied from the test setup in spi2davex.
> hope that helps
> angela
>
>> Thank you !
>> John
>>
>>
>

Re: Jackrabbit 1.6 and DavEx ?

Posted by Angela Schreiber <an...@day.com>.
hi john

> So my question is : is it possible to have a DavEx remote connection to 
> a repository with the API 1.6 ?
> I tried to figure out by myself by browsing the docs and the list, but I 
> couldn't find this information. I just saw the package spi2davex that 
> gives me some hope.

when there is such a package it should be possible.
there are quite some issues fixed since then (-> see jira)
but apart from that it should work.

> If it's possible to do it, I would be glad to have a snippet of code to 
> establish the connection. I've found it for the version 2.0 but I guess 
> the Utils class used is proper to 2.0.

you can easily create the connection by manually creating the
jcr2spi Repository instance. something like:

String url = <your server url>;
final RepositoryService service = createService(url) // see below;
Repository repository = RepositoryImpl.create(new 
AbstractRepositoryConfig() {
                     public RepositoryService getRepositoryService() {
                         return service;
                     }
                 });

private RepositoryService createService(String uri) throws 
RepositoryException {
         BatchReadConfig brc = new BatchReadConfig() {
             public int getDepth(Path path, PathResolver resolver) 
throws NamespaceException {
                 return 4;
             }
         };
         return new RepositoryServiceImpl(uri, brc);
     }

that code is copied from the test setup in spi2davex.
hope that helps
angela
> Thank you !
> John
>