[Pellet-Users] [DIG] Exception when querying for an object while property is undefined

Franz Schenk schenk at informatik.uni-goettingen.de
Thu May 11 02:57:27 EDT 2006


Hello Evren,

thanks again for your help. I attached a minimal example as well as the ontology. When I run the code here, I get the following output:



Query 0: select ?x ?y where { ?x <http://localhost/test.owl#gives_lecture> ?y . }
<variable name="x">
http://localhost/test.owl#MadProfessor
</variable>
<variable name="y">
http://localhost/test.owl#Lecture1
</variable>

Query 1: select ?y    where { <http://localhost/test.owl#MadProfessor> <http://localhost/test.owl#gives_lecture> ?y . }
<variable name="y">
http://localhost/test.owl#Lecture1
</variable>

Query 2: select ?x    where { ?x <http://localhost/test.owl#gives_lecture> <http://localhost/test.owl#Lecture1> . }
<variable name="x">
http://localhost/test.owl#MadProfessor
</variable>

Query 3: select ?x    where { ?x <http://localhost/test.owl#gives_session> <http://localhost/test.owl#Lecture1> . }

Reason of failure: com.hp.hpl.jena.shared.QueryStageException: rethrew: com.hp.hpl.jena.reasoner.dig.DIGErrorResponseException: DIG error: General Ask Error - (no message)
General SPARQL failure: java.lang.RuntimeException: class com.hp.hpl.jena.graph.query.BufferPipe$Finished
Query 4: select ?y	 where { <http://localhost/test.owl#MadProfessor> <http://localhost/test.owl#gives_session> ?y . }
Incorrect request. Maybe wrong SPARQL-Syntax?


Now I'm really curious whether you get the same results or not. 

Best,
Franz






On Wed, 10 May 2006 12:04:39 -0400
Evren Sirin <evren at cs.umd.edu> wrote:

> Oh, I thought this e-mail was replied. I've tried the ontology attached 
> (basically the snippet you sent earlier) and the code attached 
> (straight-forward query evaluation) with pellet 1.3 and I got no 
> exceptions just empty set. I didn't try the code below but I believe it 
> is basically the same thing (and there are some compilation errors 
> because some part of the code where variables are defined is missing).
> 
> If there is a complete and minimal example (both ontology and code) that 
> we can compile and run directly we might figure out what the problem is.
> 
> Evren
> 
> On 5/10/2006 4:41 AM, Franz Schenk wrote:
> > Hello Evren,
> >
> > I already sent this reply, but, accidentally, not to the list but to your email-address instead. So once again and for all to see:
> >
> >
> > thanks for your help. The version of pellet I use is:
> > Pellet 1.3 (Apr 17, 2005)
> >
> > Here is the java-code, that I used for querying:
> >
> > 	public String SPARQLquery(String requeststring, OntModel ontmodel){
> > 		Vector<String> variables = parseRequest(requeststring);
> > 		String string="Failure";
> > 		StringBuilder buffer = new StringBuilder();
> > 		try{
> > 			com.hp.hpl.jena.query.Query query = QueryFactory.create(requeststring) ;
> > 			com.hp.hpl.jena.query.QueryExecution qexec = QueryExecutionFactory.create(query, ontmodel) ;
> > 			try{
> > 				ResultSet results = qexec.execSelect();
> > 				for (  ; results.hasNext() ; )
> > 				{
> > 					QuerySolution soln = results.nextSolution();
> > 					for(int i=0; i<variables.size(); i++)
> > 					{
> > 						String var = variables.get(i);
> > 						Object x = soln.get(var);
> > 						buffer.append("<variable name=\""+var+"\">\n"); 
> > 						buffer.append(x+"\n");
> > 						buffer.append("</variable>\n");
> > 					}
> > 				}
> > 				string = buffer.toString();
> > 			}
> > 			catch(Exception qe){
> > 				string ="Incorrect request. Maybe wrong SPARQL-Syntax?";	
> > 				System.out.println("Reason of failure: "+qe.toString());
> > 			}
> > 			finally{qexec.close();}
> > 		}
> > 		catch(Exception e){System.out.println("General SPARQL failure: "+
> > 				e.toString());}
> > 		return string;
> > 	}
> > 	public static Vector<String> parseRequest(String requeststring)
> > 	{
> > 		String requestinsensitiv = requeststring.toUpperCase();
> > 		int indexbegin = requestinsensitiv.indexOf("SELECT")+6;		
> > 		int indexend = requestinsensitiv.indexOf("FROM");
> > 		if (indexend == -1)
> > 		{
> > 			indexend = requestinsensitiv.indexOf("WHERE");
> > 			if (indexend == -1)
> > 				indexend = requeststring.length();
> > 		}
> > 		String allvars = requeststring.substring(indexbegin, indexend).trim();		
> > 		Vector<String> variables = new Vector<String>();
> > 		String variable;
> > 		while(allvars.length() >0){
> > 			int delimiter = allvars.indexOf(" ");
> > 			//variable is the first variable bevor the delimiter
> > 			if (delimiter >0)
> > 				aktuell = allvars.substring(0,delimiter).trim();
> > 			else
> > 			{
> > 				variable = allvars.trim();
> > 				delimiter = allvars.length()-1;
> > 			}
> > 			//cut off the questionmark
> > 			variable = variable.substring(1);			
> > 			//add the variable to the vector
> > 			variables.addElement(variable);
> > 			allvars = allvars.substring(delimiter+1);
> > 		}		
> > 		return variables;		
> > 	}
> >
> > I use the ontology that I already sent with the original posting. The ontmodel is beeing created in the usual fashion like:
> >
> > 	Resource conf = model.createResource();
> > 	conf.addProperty( ReasonerVocabulary.EXT_REASONER_URL, 
> > 		model.createResource( "http://localhost:8081" ) );  
> > 		    
> > 	DIGReasonerFactory drf = (DIGReasonerFactory) ReasonerRegistry.theRegistry().getFactory( DIGReasonerFactory.URI );
> > 	DIGReasoner digReasoner = (DIGReasoner) drf.create( conf );
> > 	OntModelSpec spec = new OntModelSpec( OntModelSpec.OWL_DL_MEM);
> > 	spec.setReasoner( digReasoner);
> > 	OntModel ontmodel = ModelFactory.createOntologyModel( spec,model);
> > 	
> >
> > The following queries work as expected:
> > - select ?x ?y where { ?x <http://localhost/test.owl#gives_lecturse> ?y . }
> > - select ?y    where { <http://localhost/test.owl#MadProfessor> <http://localhost/test.owl#gives_lecture> ?y . }
> > - select ?x    where { ?x <http://localhost/test.owl#gives_lecture> <http://localhost/test.owl#Lecture1> . }
> > - select ?x    where { ?x <http://localhost/test.owl#gives_session> <http://localhost/test.owl#Lecture1> . }
> >   [this one results in an empty resultset, as expected]
> > - select ?x ?y where { <http://localhost/test.owl#MadProfessor> <http://localhost/test.owl#gives_session> ?y . }
> >   but this last one fails, with the following error:
> >
> > Reason of failure: com.hp.hpl.jena.shared.QueryStageException: rethrew: com.hp.hpl.jena.reasoner.dig.DIGErrorResponseException: DIG error: General Ask Error - (no message)
> > General SPARQL failure: java.lang.RuntimeException: class com.hp.hpl.jena.graph.query.BufferPipe$Finished
> > Query: Incorrect request. Maybe wrong SPARQL-Syntax?
> >
> >
> > Do you see any reason, why this happens?
> >
> > Greetings,
> > Franz
> >
> > On Tue, 02 May 2006 21:14:04 -0400
> > Evren Sirin <evren at cs.umd.edu> wrote:
> >
> >   
> >> Are you trying this example with the latest 1.3 (non-beta) release? I 
> >> didn't get any errors with the latest version. If the problem still 
> >> exists, can you also post the code you are using?
> >>
> >> Thanks,
> >> Evren
> >>
> >> On 4/24/2006 4:45 AM, Franz Schenk wrote:
> >>     
> >>> Hello,
> >>>
> >>> I have some problems with SPARQL-queries in combination with
> >>> DIG-reasoners, maybe some of you can give me a hand here?
> >>>
> >>> I already asked the jena-guys about this in the first place, part of the answers (that brought me here) was:
> >>> "Whenever the DIG interface DIGErrorResponseException, it means that the remote 
> >>> end reported a problem encoded in the XML response. So the error is in the 
> >>> Pellet reasoner itself, not the interface."
> >>>
> >>>
> >>> When I use Pellet (latest 1.3) via DIG-Interface and start the
> >>> following SPARQL-query from my application, using the jena-api:
> >>>
> >>> select ?x where
> >>> {
> >>> <http://localhost/test.owl#MadProfessor>
> >>> <http://localhost/test.owl#undefined_property>
> >>> ?x .
> >>> }
> >>>
> >>>
> >>> i receive the following error message (instead of an empty result set,
> >>> which is what i was expecting):
> >>> com.hp.hpl.jena.shared.QueryStageException: rethrew: 
> >>> com.hp.hpl.jena.reasoner.dig.DIGErrorResponseException: 
> >>> DIG error: General Ask Error - (no message)
> >>> java.lang.RuntimeException: class com.hp.hpl.jena.graph.query.BufferPipe$Finished
> >>>
> >>> The output  of pellet was:
> >>>
> >>> PelletDIGServer Version 1.3 (April 17 2006)
> >>> Port: 8081
> >>> java.lang.NullPointerException
> >>>         at org.mindswap.pellet.KnowledgeBase.getPropertyValues(KnowledgeBase.java:2148)
> >>>         at org.mindswap.pellet.dig.DIGAskHandler.roleFillers(DIGAskHandler.java:315)
> >>>         at org.mindswap.pellet.dig.DIGAskHandler.asks(DIGAskHandler.java:128)
> >>>         at org.mindswap.pellet.dig.PelletDIGReasoner.process(PelletDIGReasoner.java:155)
> >>>         at org.mindswap.pellet.dig.PelletDIGReasoner.process(PelletDIGReasoner.java:107)
> >>>         at org.mindswap.pellet.dig.PelletDIGServer.handle(PelletDIGServer.java:74)
> >>>         at org.mortbay.http.HttpContext.handle(HttpContext.java:1565)
> >>>         at org.mortbay.http.HttpContext.handle(HttpContext.java:1517)
> >>>         at org.mortbay.http.HttpServer.service(HttpServer.java:954)
> >>>         at org.mortbay.http.HttpConnection.service(HttpConnection.java:816)
> >>>         at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:983)
> >>>         at org.mortbay.http.HttpConnection.handle(HttpConnection.java:833)
> >>>         at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244)
> >>>         at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
> >>>         at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
> >>>
> >>>
> >>> And this is what my ontologgy looks like:
> >>>
> >>>     <owl:Class rdf:ID="Person"/>
> >>>     <owl:Class rdf:ID="Professor">
> >>>         <rdfs:subClassOf rdf:resource="#Person"/>
> >>>     </owl:Class>
> >>>     <owl:Class rdf:ID="Lecture"/>
> >>>
> >>>     <owl:ObjectProperty rdf:ID="gives_lecture">
> >>>         <rdfs:domain rdf:resource="#Professor"/>
> >>>         <rdfs:range rdf:resource="#Lecture"/>
> >>>     </owl:ObjectProperty>
> >>>
> >>>     <owl:Thing rdf:ID="Lecture1">
> >>>         <rdf:type rdf:resource="#Lecture"/>
> >>>     </owl:Thing>
> >>>
> >>>     <owl:Thing rdf:ID="MadProfessor">
> >>>         <rdf:type rdf:resource="#Professor"/>
> >>>         <test:gives_lecture  rdf:resource="#Lecture1"/>
> >>>     </owl:Thing>
> >>>
> >>>
> >>> If I use one of the jena-built-in reasoners, then everything is fine, I just receive an empty result set.
> >>> Another query, where I ask for the subject instead of the object (but again
> >>> with an property undefined wrt the ontology)
> >>>
> >>> select ?x where
> >>> {
> >>> ?x
> >>> <http://localhost/test.owl#undefined_property>
> >>> <http://localhost/test.owl#Lecture1> .
> >>> }
> >>>
> >>>
> >>> would result in an empty result set, just as i would expect.
> >>>
> >>> I use Jena 2.3  and pellet1.3 (and also tried with Racer 1.7.24). As the problem persists with both Pellet and Racer, I'm not sure wether this is some limitation due to the DIG-Interface, or maybe there is any other explanation for the failure of query-execution in the
> >>> first case that I described above? Or a bug?
> >>>
> >>> Thanks for any help!
> >>>
> >>> Greetings,
> >>> Franz
> >>>
> >>>
> >>>
> >>>   
> >>>       
> >
> >
> >   
> 
> 


-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TestSPARQL.java
Type: text/x-java
Size: 4499 bytes
Desc: not available
Url : http://lists.mindswap.org/pipermail/pellet-users/attachments/20060511/700dcf04/attachment-0001.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test3.owl
Type: application/octet-stream
Size: 944 bytes
Desc: not available
Url : http://lists.mindswap.org/pipermail/pellet-users/attachments/20060511/700dcf04/attachment-0001.obj 


More information about the Pellet-Users mailing list