jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Guggisberg <stefan.guggisb...@gmail.com>
Subject Re: Node.getProperty(String arg0) fails with javax.jcr.PathNotFoundException: jcr:data
Date Thu, 14 Mar 2013 16:50:58 GMT
On Thursday, March 14, 2013, Ulrich wrote:

> When running this code:
>
>
> Property jcrdata;
> for (PropertyIterator pi = fileNode.getProperties(); pi.hasNext(); ) {
>         Property p = pi.nextProperty();
>         LOGGER.info("Property is: " + p.getName() + "=" +
> p.getValue().getString());
> }
> jcrdata = fileNode.getProperty("jcr:data");
>
> the for-loop works fine and displays the property "jcr:data" and it's
> value. But
> the last line:
>        Property jcrdata = fileNode.getProperty("jcr:data");
> fails with "javax.jcr.PathNotFoundException: jcr:data".


what is the node type of fileNode?

i assume it's nt:file. nt:file doesn't declare a jcr:data property.
it declares a jcr:content node which commonly is a nt:resource.
nt:resource does declare a jcr:data property.

i.e. fileNode.getNode("jcr:content").getProperty("jcr:data")

cheers
stefan

When I change the code to
> Property jcrdata;
> for (PropertyIterator pi = fileNode.getProperties(); pi.hasNext(); ) {
>      Property p = pi.nextProperty();
>      LOGGER.info("Property is: " + p.getName() + "=" +
> p.getValue().getString());
>      if (p.getName().equals("jcr:data")) {
>         jcrdata = p;
> }
> the program works fine.
>
> I don't see what might go wrong in the first sample. I would rather prefer
> the
> first one. Does anyone has an explanation for this?
>
> Ulrich
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message