4 Replies Latest reply on Nov 26, 2013 4:16 AM by fazileh

    Iterator.nextNode() throws java.util.NoSuchElementException

    fazileh

      I have some nodes in my repository, but when I iterate them by blew code:

      1-          NodeIterator it = myNodes.getNodes();    

      2-          while (it.hasNext()) {

      3-              Node node = it.nextNode();

                     ...

                  }

      In line 2 it.hasNext() is true, BUT it.nextNode() throws an exception java.util.NoSuchElementException!
      And it (NodeIterator) is null!
      I will appreciate if someone help me.

       

       

       

       

        • 1. Re: Iterator.nextNode() throws java.util.NoSuchElementException
          rhauch

          What version of ModeShape are you using? Are you using ACLs? Can you provide a repeatable test case? We'd be happy to help, but we need more information to work with.

          • 2. Re: Iterator.nextNode() throws java.util.NoSuchElementException
            fazileh

            Thanks for your attention. I'm using ModeShpae 3.6.0. No, I don't use ACLs, I will try provide a test case. I'm sure my code is correct, and I think the problem is about 's data. but I don't know what is it.

            I have another question here: Is there any thing cause one node In modeshape_web_explorer does not show own children? Because In the modeshape-web-explorer when I click on a node in repository tree It does not show children, while the I know this node has many nodes as child.

             

            Thank you

            • 3. Re: Iterator.nextNode() throws java.util.NoSuchElementException
              rhauch

              Thanks for your attention. I'm using ModeShpae 3.6.0. No, I don't use ACLs, I will try provide a test case. I'm sure my code is correct, and I think the problem is about 's data. but I don't know what is it.

              Thanks. A test case would be very helpful. There are also a couple other things that might explain it, so you could check:

              • Given that your code is using a Session in one thread to read through the nodes, is there another thread that is using the same Session to modify content? That'd be very bad and is a no-no with JCR.
              • Is there another thread using a different session to modify the children that you're looking at in your session? That is something that can happen, but you application has to deal with. It's akin to making a query against a relational DB, finding a specific row, having another connection remove that row, and then you attempting to read the now-removed row.

              I have another question here: Is there any thing cause one node In modeshape_web_explorer does not show own children? Because In the modeshape-web-explorer when I click on a node in repository tree It does not show children, while the I know this node has many nodes as child.

              That would be unexpected, except in the above cases of concurrent modification (when some or all of the children really have been removed). Can you explain what you're doing in the web explorer? Maybe that will help us figure it out. BTW, the web explorer is brand new, so it's not been fully vetted.

              • 4. Re: Iterator.nextNode() throws java.util.NoSuchElementException
                fazileh

                I have just one session working on a repository.

                and I think this exception is about my problem in modeshape_web_explorer (don't see child's node)

                 

                If it helps, complete exception is:

                Caused by: java.util.NoSuchElementException

                  at org.modeshape.jcr.cache.document.ImmutableChildReferences$Segmented$2.next(ImmutableChildReferences.java:549)

                  at org.modeshape.jcr.cache.document.ImmutableChildReferences$Segmented$2.next(ImmutableChildReferences.java:516)

                  at org.modeshape.jcr.JcrChildNodeIterator.nextNode(JcrChildNodeIterator.java:112)

                  at org.modeshape.web.server.JcrServiceImpl.childNodes(JcrServiceImpl.java:163)

                  at sun.reflect.GeneratedMethodAccessor25.invoke(Unknown Source)

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                  at java.lang.reflect.Method.invoke(Method.java:601)

                  at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561)

                  ... 24 more