You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Sebastian Lindstaedt <Se...@vaberlin.de> on 2013/07/17 13:47:37 UTC

Resultless XPath Queries

Hi,

I'm migrating an Jackrabbit Application from JBoss EAP 5 to JBoss EAP 6 (aka. JBoss 7.1.3.Final-redheat-4).
The Migration of Jackrabbit (from 1.5-jca to 2.5.3-jca) causes a bit of trouble with XPath Queries.

To get jackrabbit-jca-2.5.3.rar running in the JBoss I modified it, as shown here (https://community.jboss.org/wiki/JackrabbitDeploymentInAS6AndAS7) and here (http://www.javaworld.com/community/node/8185)

After Deployment JBoss starts and the repository gets created.

In my EJB Application I inject the repository as a Resource
<code>
   Class MySessionBean ...{
     ...
    @Resource(mappedName = "java:jboss/jca/DocumentStore", type = javax.jcr.Repository.class, authenticationType = javax.annotation.Resource.AuthenticationType.CONTAINER)
    Repository                  repo;
    ...
    }
</code>

With this injected Repository I can:
- create nodes:
    <code>
    Node node = rootNode.addNode("test", "nt:unstructured");
    </code>

- list existing nodes:
    <code>
    session.getRootNode().getNodes();
    </code>

- run JCR-SQL2 Queries, showing plenty of nodes
    <code>
    "SELECT * FROM [nt:unstructured]"
    </code>

But unfortunately any XPath Query returns without any result
Query: "//*"  Result: queryresult.size = -1
Query: "//*[jcr:contains(., '*')]" Result: queryresult.size = -1


As far as I understand XPath is deprecated but still working. Using the same XPath queries in the Jackrabbitexplorer (http://code.google.com/p/jackrabbitexplorer/) against the Jackrabbit-WebApp (which uses its own repository, not the one the jca adapter creates) delivers expected results.

Is there anything left I need to configure to make XPath working?

I'm thankful for any hint.

Mit freundlichen Grüßen
i.A. Sebastian Lindstaedt
Projektingenieur

Verkehrsautomatisierung Berlin GmbH
Fanny-Zobel-Str. 9
12435 Berlin
Deutschland

phone: +49 30 5362 2581
Sebastian.Lindstaedt@vaberlin.de<ma...@vaberlin.de> I www.vaberlin.de<http://www.vaberlin.de/>
Confidentiality statement and Disclaimer:
Diese E-Mail enthält vertrauliche oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet. +++ This email may contain confidential or privileged information. If you are not the intended recipient (or have received this email in error) please notify the sender immediately and destroy this email. Any unauthorized copying, disclosure or distribution of the material in this email is strictly forbidden.

Rechtsform: GmbH, Sitz Berlin,
Registergericht: Amtsgericht Berlin-Charlottenburg, HRB 37007
Geschäftsführer: Christian Scheiter, Christian Schmidt, Michael Hanning
Ust.Id.-Nr.: DE 137200538, St.-Nr. : 37/232/10491


-- 
This email was Virus checked by Astaro Security Gateway. http://www.astaro.com

AW: Resultless XPath Queries

Posted by Sebastian Lindstaedt <Se...@vaberlin.de>.
Hi,

thank you very much for the hint!

Sebastian

-----Ursprüngliche Nachricht-----
Von: Jeroen Reijn [mailto:j.reijn@onehippo.com] 
Gesendet: Donnerstag, 22. August 2013 15:17
An: users@jackrabbit.apache.org
Betreff: Re: Resultless XPath Queries

Hi,

as of Jackrabbit 2 you will need an order by clause to get a valid result out of the size. Also see http://jackrabbit.apache.org/frequently-asked-questions.html at the bottom of the page.

Jeroen


On Wed, Jul 17, 2013 at 3:40 PM, Sebastian Lindstaedt < Sebastian.Lindstaedt@vaberlin.de> wrote:

> Hi Julian,
>
> Thank you very much, you were absolutely correct! The nodes where there.
>
> Interestingly the code that I'm dealing with has plenty of such places 
> where it relies on the described behavior.
>
> <code>
> result.getNodes().getSize() >= 1
> </code>
>
> Checking the different Versions of RangeIterator (
> http://grepcode.com/file/repo1.maven.org/maven2/javax.jcr/jcr/1.0/java
> x/jcr/RangeIterator.java/) I'm wondering how that worked over the 
> course of years. Maybe the Implementation of RangeIterator in the old 
> Jackrabbit Version (1.5) did always knew how many nodes it contained 
> :-)
>
>
> Best regards,
>
> Sebastian
>
> -----Ursprüngliche Nachricht-----
> Von: Julian Reschke [mailto:julian.reschke@gmx.de]
> Gesendet: Mittwoch, 17. Juli 2013 14:09
> An: users@jackrabbit.apache.org
> Cc: Sebastian Lindstaedt
> Betreff: Re: Resultless XPath Queries
>
> On 2013-07-17 13:47, Sebastian Lindstaedt wrote:
> > Hi,
> >
> > I'm migrating an Jackrabbit Application from JBoss EAP 5 to JBoss 
> > EAP 6
> (aka. JBoss 7.1.3.Final-redheat-4).
> > The Migration of Jackrabbit (from 1.5-jca to 2.5.3-jca) causes a bit 
> > of
> trouble with XPath Queries.
> >
> > To get jackrabbit-jca-2.5.3.rar running in the JBoss I modified it, 
> > as shown here
> > (https://community.jboss.org/wiki/JackrabbitDeploymentInAS6AndAS7) 
> > and here (http://www.javaworld.com/community/node/8185)
> >
> > After Deployment JBoss starts and the repository gets created.
> >
> > In my EJB Application I inject the repository as a Resource <code>
> >     Class MySessionBean ...{
> >       ...
> >      @Resource(mappedName = "java:jboss/jca/DocumentStore", type =
> javax.jcr.Repository.class, authenticationType =
> javax.annotation.Resource.AuthenticationType.CONTAINER)
> >      Repository                  repo;
> >      ...
> >      }
> > </code>
> >
> > With this injected Repository I can:
> > - create nodes:
> >      <code>
> >      Node node = rootNode.addNode("test", "nt:unstructured");
> >      </code>
> >
> > - list existing nodes:
> >      <code>
> >      session.getRootNode().getNodes();
> >      </code>
> >
> > - run JCR-SQL2 Queries, showing plenty of nodes
> >      <code>
> >      "SELECT * FROM [nt:unstructured]"
> >      </code>
> >
> > But unfortunately any XPath Query returns without any result
> > Query: "//*"  Result: queryresult.size = -1
> > Query: "//*[jcr:contains(., '*')]" Result: queryresult.size = -1
>
> Result size -1 means "unknown", not empty. You'll need to iterate 
> through the result set...
>
> Best regards, Julian
>
> --
> This email was Virus checked by Astaro Security Gateway.
> http://www.astaro.com
>



--
Jeroen Reijn
Solution Architect
Hippo

Amsterdam - Oosteinde 11, 1017 WT Amsterdam Boston - 101 Main Street, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com

http://about.me/jeroenreijn

--
This email was Virus checked by Astaro Security Gateway. http://www.astaro.com

Re: Resultless XPath Queries

Posted by Jeroen Reijn <j....@onehippo.com>.
Hi,

as of Jackrabbit 2 you will need an order by clause to get a valid result
out of the size. Also see
http://jackrabbit.apache.org/frequently-asked-questions.html at the bottom
of the page.

Jeroen


On Wed, Jul 17, 2013 at 3:40 PM, Sebastian Lindstaedt <
Sebastian.Lindstaedt@vaberlin.de> wrote:

> Hi Julian,
>
> Thank you very much, you were absolutely correct! The nodes where there.
>
> Interestingly the code that I'm dealing with has plenty of such places
> where it relies on the described behavior.
>
> <code>
> result.getNodes().getSize() >= 1
> </code>
>
> Checking the different Versions of RangeIterator (
> http://grepcode.com/file/repo1.maven.org/maven2/javax.jcr/jcr/1.0/javax/jcr/RangeIterator.java/)
> I'm wondering how that worked over the course of years. Maybe the
> Implementation of RangeIterator in the old Jackrabbit Version (1.5) did
> always knew how many nodes it contained :-)
>
>
> Best regards,
>
> Sebastian
>
> -----Ursprüngliche Nachricht-----
> Von: Julian Reschke [mailto:julian.reschke@gmx.de]
> Gesendet: Mittwoch, 17. Juli 2013 14:09
> An: users@jackrabbit.apache.org
> Cc: Sebastian Lindstaedt
> Betreff: Re: Resultless XPath Queries
>
> On 2013-07-17 13:47, Sebastian Lindstaedt wrote:
> > Hi,
> >
> > I'm migrating an Jackrabbit Application from JBoss EAP 5 to JBoss EAP 6
> (aka. JBoss 7.1.3.Final-redheat-4).
> > The Migration of Jackrabbit (from 1.5-jca to 2.5.3-jca) causes a bit of
> trouble with XPath Queries.
> >
> > To get jackrabbit-jca-2.5.3.rar running in the JBoss I modified it, as
> > shown here
> > (https://community.jboss.org/wiki/JackrabbitDeploymentInAS6AndAS7) and
> > here (http://www.javaworld.com/community/node/8185)
> >
> > After Deployment JBoss starts and the repository gets created.
> >
> > In my EJB Application I inject the repository as a Resource <code>
> >     Class MySessionBean ...{
> >       ...
> >      @Resource(mappedName = "java:jboss/jca/DocumentStore", type =
> javax.jcr.Repository.class, authenticationType =
> javax.annotation.Resource.AuthenticationType.CONTAINER)
> >      Repository                  repo;
> >      ...
> >      }
> > </code>
> >
> > With this injected Repository I can:
> > - create nodes:
> >      <code>
> >      Node node = rootNode.addNode("test", "nt:unstructured");
> >      </code>
> >
> > - list existing nodes:
> >      <code>
> >      session.getRootNode().getNodes();
> >      </code>
> >
> > - run JCR-SQL2 Queries, showing plenty of nodes
> >      <code>
> >      "SELECT * FROM [nt:unstructured]"
> >      </code>
> >
> > But unfortunately any XPath Query returns without any result
> > Query: "//*"  Result: queryresult.size = -1
> > Query: "//*[jcr:contains(., '*')]" Result: queryresult.size = -1
>
> Result size -1 means "unknown", not empty. You'll need to iterate through
> the result set...
>
> Best regards, Julian
>
> --
> This email was Virus checked by Astaro Security Gateway.
> http://www.astaro.com
>



-- 
Jeroen Reijn
Solution Architect
Hippo

Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 101 Main Street, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com

http://about.me/jeroenreijn

AW: Resultless XPath Queries

Posted by Sebastian Lindstaedt <Se...@vaberlin.de>.
Hi Julian,

Thank you very much, you were absolutely correct! The nodes where there.

Interestingly the code that I'm dealing with has plenty of such places where it relies on the described behavior.

<code>
result.getNodes().getSize() >= 1
</code>

Checking the different Versions of RangeIterator (http://grepcode.com/file/repo1.maven.org/maven2/javax.jcr/jcr/1.0/javax/jcr/RangeIterator.java/) I'm wondering how that worked over the course of years. Maybe the Implementation of RangeIterator in the old Jackrabbit Version (1.5) did always knew how many nodes it contained :-)


Best regards, 

Sebastian

-----Ursprüngliche Nachricht-----
Von: Julian Reschke [mailto:julian.reschke@gmx.de] 
Gesendet: Mittwoch, 17. Juli 2013 14:09
An: users@jackrabbit.apache.org
Cc: Sebastian Lindstaedt
Betreff: Re: Resultless XPath Queries

On 2013-07-17 13:47, Sebastian Lindstaedt wrote:
> Hi,
>
> I'm migrating an Jackrabbit Application from JBoss EAP 5 to JBoss EAP 6 (aka. JBoss 7.1.3.Final-redheat-4).
> The Migration of Jackrabbit (from 1.5-jca to 2.5.3-jca) causes a bit of trouble with XPath Queries.
>
> To get jackrabbit-jca-2.5.3.rar running in the JBoss I modified it, as 
> shown here 
> (https://community.jboss.org/wiki/JackrabbitDeploymentInAS6AndAS7) and 
> here (http://www.javaworld.com/community/node/8185)
>
> After Deployment JBoss starts and the repository gets created.
>
> In my EJB Application I inject the repository as a Resource <code>
>     Class MySessionBean ...{
>       ...
>      @Resource(mappedName = "java:jboss/jca/DocumentStore", type = javax.jcr.Repository.class, authenticationType = javax.annotation.Resource.AuthenticationType.CONTAINER)
>      Repository                  repo;
>      ...
>      }
> </code>
>
> With this injected Repository I can:
> - create nodes:
>      <code>
>      Node node = rootNode.addNode("test", "nt:unstructured");
>      </code>
>
> - list existing nodes:
>      <code>
>      session.getRootNode().getNodes();
>      </code>
>
> - run JCR-SQL2 Queries, showing plenty of nodes
>      <code>
>      "SELECT * FROM [nt:unstructured]"
>      </code>
>
> But unfortunately any XPath Query returns without any result
> Query: "//*"  Result: queryresult.size = -1
> Query: "//*[jcr:contains(., '*')]" Result: queryresult.size = -1

Result size -1 means "unknown", not empty. You'll need to iterate through the result set...

Best regards, Julian

--
This email was Virus checked by Astaro Security Gateway. http://www.astaro.com

Re: Resultless XPath Queries

Posted by Julian Reschke <ju...@gmx.de>.
On 2013-07-17 13:47, Sebastian Lindstaedt wrote:
> Hi,
>
> I'm migrating an Jackrabbit Application from JBoss EAP 5 to JBoss EAP 6 (aka. JBoss 7.1.3.Final-redheat-4).
> The Migration of Jackrabbit (from 1.5-jca to 2.5.3-jca) causes a bit of trouble with XPath Queries.
>
> To get jackrabbit-jca-2.5.3.rar running in the JBoss I modified it, as shown here (https://community.jboss.org/wiki/JackrabbitDeploymentInAS6AndAS7) and here (http://www.javaworld.com/community/node/8185)
>
> After Deployment JBoss starts and the repository gets created.
>
> In my EJB Application I inject the repository as a Resource
> <code>
>     Class MySessionBean ...{
>       ...
>      @Resource(mappedName = "java:jboss/jca/DocumentStore", type = javax.jcr.Repository.class, authenticationType = javax.annotation.Resource.AuthenticationType.CONTAINER)
>      Repository                  repo;
>      ...
>      }
> </code>
>
> With this injected Repository I can:
> - create nodes:
>      <code>
>      Node node = rootNode.addNode("test", "nt:unstructured");
>      </code>
>
> - list existing nodes:
>      <code>
>      session.getRootNode().getNodes();
>      </code>
>
> - run JCR-SQL2 Queries, showing plenty of nodes
>      <code>
>      "SELECT * FROM [nt:unstructured]"
>      </code>
>
> But unfortunately any XPath Query returns without any result
> Query: "//*"  Result: queryresult.size = -1
> Query: "//*[jcr:contains(., '*')]" Result: queryresult.size = -1

Result size -1 means "unknown", not empty. You'll need to iterate 
through the result set...

Best regards, Julian