Hi Miklos,

Miklos Pocsaji wrote:
I get a NoSuchElementException running the following code

QueryResult result = QueryHelper.query(session, qstr.toString(), "xpath");
NodeIterator ni = result.getNodes();
while (ni.hasNext())
    {
      Node newsitem = ni.nextNode(); // ***
      // ...
    }
</snip>
Seems like the index is not coherent with the data stored. I am really
confused by this error, any ideas?

Could you please try to find out what node in the index caused this error? I know it might be a bit tricky but it would help a lot to find the cause for this error. You should find an error message in the logs which states the uuid of the missing node. with this information you should be able to find the lucene document in one of the indexes in the workspace folder. Using a tool like Luke (http://www.getopt.org/luke/luke.jnlp) can help you on this journey ;)

I'm also interested to see, if the error also occurs if you restrict the query to only a subtree of the workspace. but maybe you're doing that already...

As a short term solution, you can delete the index in the workspace folder. The index is recreated on startup if it is missing.

(Is it possible that unclosed sessions cause this error?)

well, the only situation where you can really force this error to happen, is, to delete a node (but not save its parent) and then search for something that matches the deleted node. That's because the index is based on the persistent view of the workspace, as specified by jsr-170.

Fabrizio Giustina encountered a similar error: http://thread.gmane.org/gmane.comp.apache.jackrabbit.devel/2363

But we haven't received any feedback whether he had been able to reproduce his error with a JUnit test.

Anyway, I created a JIRA issue to keep track of this error:
http://issues.apache.org/jira/browse/JCR-160

regards
 marcel

Reply via email to