After spending a few hours, I found that this was a problem with the version of java that my web server was using. I upgraded from 1.2.2 to 1.3.1_06 and it worked like a charm.
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Monday, December 23, 2002 4:41 PM To: [EMAIL PROTECTED] Subject: Iterator Problem : Please help Please help with this: I'm getting the following error when I call next() on Iterator. However hasNext() returns true. if I do a getCount on broker, then it correctly returns the number of records. Any idea what the problem here could be? Thanks, Gaurav ----------------------------------------EXCEPTION--------------------------- ----------------------------------------- [23/Dec/2002:16:19:53] failure ( 526): Internal error: exception thrown from the servlet service function (uri=/ojb/test.do): java.util.NoSuchElementException, Stack: java.util.NoSuchElementException at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(Un known Source) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(Un known Source) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(Un known Source) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(Un known Source) at org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.getCollectionByQu ery(Unknown Source) at com.gecapital.erc.phoenix.test.TestServlet.getTableIterator(Unknown Source) at com.gecapital.erc.phoenix.test.TestServlet.doGet(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at com.iplanet.server.http.servlet.NSServletRunner.invokeServletService(NSServl etRunner.java:897) at com.iplanet.server.http.servlet.WebApplication.service(WebApplication.java:1 059) at com.iplanet.server.http.servlet.NSServletRunner.ServiceWebApp(NSServletRunne r.java:959) -------------------------------------------CODE----------------------------- ------------------------------------- protected Iterator getTableIterator() throws IOException { Iterator result = null; Collection cresult = null; PersistenceBroker broker = null; try { broker = getBroker(); } catch (Exception ex) { throw new IOException(ex.getMessage()); } Criteria selectAll = null; Query query = QueryFactory.newQuery(MBudget.class, selectAll); cresult = broker.getCollectionByQuery(query); result = cresult.iterator(); //this.getServletContext().log(Integer.toString(broker.getCount(query))); broker.close(); return result; } protected void writeTable(Iterator iter, PrintWriter writer) { writer.println("<table border=\"1\">"); writer.println("<tr><td><b>ID</b></td></tr>"); while (iter.hasNext()) { MBudget a = (MBudget) iter.next(); writer.println("<tr><td>" + a.getbudget_id() + "</td> </tr>"); writer.println("<tr><td>aaa</td> </tr>"); } writer.println("</table>"); } The iter.next() fails with NoSuchElementException -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
