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

Reply via email to