Yes. My loop breaks down to this:
while (iterator.hasNext()) {
Object obj = iterator.next();
...
}
However, if I do this instead I get (what appears to be) "normal" behavior
(except that getSize() is often much less than the actual result set size):
while (iterator.hasNext()) {
try {
Object obj = iterator.next();
} catch (NoSuchElementException excp) { /* masked */ }
}
Thanks!
brad
-----Original Message-----
From: Marcel Reutegger [mailto:[EMAIL PROTECTED]
Sent: Monday, July 14, 2008 4:35 AM
To: [email protected]
Subject: Re: RowIterator.next() fails when hasNext() returns true
Hi,
this seems very strange because LazyScoreNodeIterator always pre-fetches the
next node. so whenever you call hasNext() and it returns true
LazyScoreNodeIterator already has the next node and does not have to fetch it
on nextRow().
Can you please double check that you always call hasNext() before you call
nextRow() ?
regards
marcel
Fitzgibbons, Brad wrote:
> I'm running into this problem occasionally resulting in the exception
> below. I'm using Jackrabbit 1.4 (with core at 1.4.2). I'm using the
> H2PersistenceManager and almost all configuration values are set to
> their released default. Document order is turned off so the query is
> using a LazyScoreNodeIterator. I'm running in a transactional
> environment, and my entire execution flow is contained by a single,
> read-only, JTA transaction. The single transaction includes executing
> the query and all interactions with the returned RowIterator. If I
> ignore the NoSuchElementException's and continue using the iterator
> then there are often good results subsequent to the error. I've
> noticed that when these errors occur there are often far more results
> than are returned by RowIterator.getSize(). I realize that getSize()
> is not meant to be an accurate count of all results, but in most other
> cases getSize() is greater than the size of the result set (this may
> not be helpful). I'm using
a SQL query that involves the CONTAINS constraint (so lucene) and ordering by
jcr:score. Does this warrant a bug submission? Is there any additional
information which might help?
>
> org.springframework.web.util.NestedServletException: Request processing
> failed; nested exception is java.util.NoSuchElementException
> at
> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:535)
> at
> org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:453)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:114)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:91)
> at
> com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:103)
> at
> com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:181)
> at
> com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:266)
> at
> com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:269)
> at com.caucho.server.port.TcpConnection.run(TcpConnection.java:603)
> at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:721)
> at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:643)
> at java.lang.Thread.run(Thread.java:619)
> Caused by: java.util.NoSuchElementException
> at
> org.apache.jackrabbit.core.query.lucene.QueryResultImpl$LazyScoreNodeIterator.getScore(QueryResultImpl.java:351)
> at
> org.apache.jackrabbit.core.query.lucene.RowIteratorImpl.nextRow(RowIteratorImpl.java:153)
> at
> com.techtarget.content.data.jcr1.ElementDaoImpl.nextElement(ElementDaoImpl.java:722)
> at
> com.techtarget.content.data.jcr1.PropertyIterator.next(PropertyIterator.java:47)
> at
> com.techtarget.content.data.jcr1.PropertyIterator.next(PropertyIterator.java:21)
> at
> com.techtarget.content.web.controller.ProfileController.resourceQueryAndPrint(ProfileController.java:125)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doInvokeMethod(HandlerMethodInvoker.java:305)
> at
> org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:131)
> at
> org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:308)
> at
> org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:295)
> at
> org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:874)
> at
> org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:808)
> at
> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:523)
> at
> org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:453)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:114)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:91)
> at
> com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:103)
> at
> com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:181)
> at
> com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:266)
> at
> com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:269)
> at com.caucho.server.port.TcpConnection.run(TcpConnection.java:603)
> at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:721)
> at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:643)
> at java.lang.Thread.run(Thread.java:619)
>
> Brad Fitzgibbons
> Senior Software Engineer
> Tech Target
> The Most Targeted IT Media
> http://www.techtarget.com/
>
>
>