You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Ulrich <Fo...@gombers.de> on 2013/03/14 16:17:58 UTC

Node.getProperty(String arg0) fails with javax.jcr.PathNotFoundException: jcr:data

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

Re: Node.getProperty(String arg0) fails with javax.jcr.PathNotFoundException: jcr:data

Posted by Ulrich <Fo...@gombers.de>.

Am 14.03.2013 um 17:50 schrieb Stefan Guggisberg <st...@gmail.com>:

> 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
fileNode is the child of a "nt:file"-node and has the node-name "jcr:content". The complete code would have shown. But this is not the point here. As you can see in the second sample, the property can be processed for this node, so it is proofed, it is there (and I know it for sure - I have defined it).
There is something very strange with my repository, I think. The program used to run until today. Ok, I changed something but not here. I have no clue, how my changes may have affected the behaviour this way.

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;
}
jcrdata = fileNode.getProperty("jcr:data");

This code also fails in the last line - this proofs that the property is retrieved from the very same node.

Ulrich

Re: Node.getProperty(String arg0) fails with javax.jcr.PathNotFoundException: jcr:data

Posted by Stefan Guggisberg <st...@gmail.com>.
On Thursday, March 14, 2013, UMAIL wrote:

>
>
> Am 14.03.2013 um 17:50 schrieb Stefan Guggisberg <
> stefan.guggisberg@gmail.com <javascript:;>>:
>
> > 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
>
> fileNode is the child of a "nt:file"-node and has the node-name
> "jcr:content". The complete code would have shown. But this is not the
> point here. As you can see in the second sample, the property can be
> processed for this node, so it is proofed, it is there (and I know it for
> sure - I have defined it).
> There is something very strange with my repository, I think. The program
> used to run until today. Ok, I changed something but not here. I have no
> clue, how my changes may have affected the behaviour this way.


if you can provide a self-contained test case including your changes i'll
have a look. otherwise there's not much i can do.

cheers
stefan


> 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;
> }
> jcrdata = fileNode.getProperty("jcr:data");
>
> This code also fails in the last line - this proofs that the property is
> retrieved from the very same node.
>
> Ulrich
>
>

Re: Node.getProperty(String arg0) fails with javax.jcr.PathNotFoundException: jcr:data

Posted by UMAIL <UM...@gmx.de>.

Am 14.03.2013 um 17:50 schrieb Stefan Guggisberg <st...@gmail.com>:

> 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

fileNode is the child of a "nt:file"-node and has the node-name "jcr:content". The complete code would have shown. But this is not the point here. As you can see in the second sample, the property can be processed for this node, so it is proofed, it is there (and I know it for sure - I have defined it).
There is something very strange with my repository, I think. The program used to run until today. Ok, I changed something but not here. I have no clue, how my changes may have affected the behaviour this way.

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;
}
jcrdata = fileNode.getProperty("jcr:data");

This code also fails in the last line - this proofs that the property is retrieved from the very same node.

Ulrich


Re: Node.getProperty(String arg0) fails with javax.jcr.PathNotFoundException: jcr:data

Posted by Stefan Guggisberg <st...@gmail.com>.
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
>