You are closing the result set indirectly (by closing the QueryExecution) before you iterate it.
Result set objects in ARQ are almost always streaming and the associated QueryExecution should not be closed until you've finished iterating over the results. Rob -----Original Message----- From: "David Moss" <[email protected]> Sent: 04/01/2014 03:04 To: "[email protected]" <[email protected]> Subject: SPAM-HIGH: stream closed XMLStreamException: ParseError at [row,col]:[338,7] Message: Stream closed I thought I'd share a curious result. I've been experimenting with Jena, Fuseki and JavaServer Faces. I use Netbeans as an IDE and a Fuseki instance on my home server, connected by WiFi to my laptop. Jena and JSF are running on Tomcat on my laptop, but I have the same result when I run them directly on the server. I first populated a JSF select box with a list of resource name and title using SPARQL. Everything was good, it loaded all the data from the query into a list and used the list to populate the select list in JSF. This was a single query and the results was parsed into selectitems in a list. There are around 100 results returned by the query. All Good. Next I tried to build a list of objects using the resources returned by the first query. As each object instantiated itself it sent off a SPARQL query to Fuseki and populated its attributes. That meant about 100 separate SPARL queries. It falls over with the error at the top of this message. If I limit the results in the SPARQL to, say 30, it all works fine. If I try to instantiate 40 or more objects it falls over. I've discovered sending 100 separate SPARQL queries isn't very efficient and takes a lot of time, but I'm stumped over why sending more than 40 in succession causes it to fall over. Here is the code that instantiates the objects: //constructor public organisation(String org_resource) { org_type = new ArrayList(); setService("http://10.0.0.1:3030/ds/query"); this.setOrg_resource(org_resource); this.retrieveorg(); } public final void retrieveorg() { String query = "select ?name ?desc ?website where { " + this.getOrg_resource() + " <http://purl.org/dc/elements/1.1/title> ?name. " + this.getOrg_resource() + " <http://purl.org/dc/elements/1.1/description> ?desc. " + this.getOrg_resource() + " <http://xmlns.com/foaf/0.1/homepage> ?website. " + "} "; Query q = QueryFactory.create(query); QueryExecution qe = QueryExecutionFactory.sparqlService(getService(), q); ResultSet r = qe.execSelect(); qe.close(); if (r.hasNext()) { QuerySolution s = r.next(); this.setOrg_name(s.getLiteral("?name").toString()); this.setOrg_desc(s.getLiteral("?desc").toString()); this.setOrg_website(s.getLiteral("?website").toString()); } } // ************************************************************************** And the code that calls the constructor and builds the list of objects: public List getAllOrgs() { String query = "select ?s where { ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://admoss.info/apr/PoliticalOrganisation>. } limit 90"; ArrayList<organisation> s = new ArrayList(); Query q = QueryFactory.create(query); QueryExecution qe = QueryExecutionFactory.sparqlService(getService(), q); ResultSet r = qe.execSelect(); qe.close(); while (r.hasNext()) { QuerySolution qs = r.next(); s.add(new organisation(qs.getResource("?s").toString())); } return s; }
