jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ulrich <For...@gombers.de>
Subject Node.getProperty(String arg0) fails with javax.jcr.PathNotFoundException: jcr:data
Date Thu, 14 Mar 2013 15:17:58 GMT
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".

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
View raw message