[Pellet-users] java.util.NoSuchElementException

Michael Grove mike at clarkparsia.com
Mon Jan 28 15:57:36 UTC 2008


On Jan 27, 2008, at 12:29 PM, Christiane Telöken wrote:

> Dear Pellet users,
>
> I am using the Jena Framework with Pellet 1.5 and would like to  
> retrieve
> all the possible values of an objectproperty. Excecuting the following
> code causes an exception in the main method, although the specific
> objectproperty has some values.
>
>
> The exception goes like:
> Exception in thread "main" java.util.NoSuchElementException
>
>
> The code is:
>
> Resource prop;
> ExtendedIterator exIt = ontoModel.listObjectProperties();
>
> if (exIt != null){
>    while (exIt != null){

Just throwing this out there, but if this is your exact code, then  
its this while loop that is likely the cause of the exception.  Your  
while condition should be "while (exIt.hasNext())" because exIt will  
always be non-null according to this code, so you'll end up iterating  
right off the end of the list and you'll get the NoSuchElementException.

Cheers,

Mike


>      prop = (Resource) exIt.next();
>
>      NodeIterator nIt = (NodeIterator) ontoModel.listObjectsOfProperty
>                                        (prop, OWL.allValuesFrom);
>
>      if (nIt != null){
>        while (nIt.hasNext()){
>          RDFNode obj = (RDFNode) nIt.nextNode();
>          System.out.println (obj.toString());
>        }
>      }
>    }
> }
>
> I would be very grateful to get any hints why the code causes an  
> exception.
> :)
>
> Thank you for any help in advance,
>
> Christiane
>
>
>
> _______________________________________________
> Pellet-users mailing list
> Pellet-users at lists.owldl.com
> http://lists.owldl.com/mailman/listinfo/pellet-users
> _______________________________________________
>
> Sponsored by Clark & Parsia, LLC http://clarkparsia.com/



More information about the Pellet-users mailing list