Hi,
I have problem in JEE dynamic web project. I try to using jena library in the project to retrieve sparql query result in indx.jsp but when run time the following problem are occured :
HTTP Status 500 - Unable to compile class for JSP:
--------------------------------------------------------------------------------
type Exception report
message Unable to compile class for JSP:
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 166 in the jsp file: /Test.jsp
QueryFactory cannot be resolved
163: "PREFIX rdfs: "+
164: "select DISTINCT ?location where { ?s rdf:type dbpedia-owl:Museum . ?s dbpprop:location ?l. ?l dbpprop:nativeName ?location. ?l dbpprop:pushpinMap ?country FILTER(?country=\"Egypt\"@en && LANG(?location)='en')}";
165:
166: Query query = QueryFactory.create(sparqlQueryString2);
167: ARQ.getContext().setTrue(ARQ.useSAX);
168:
169: QueryExecution qexec = QueryExecutionFactory.sparqlService("http://DBpedia.org/sparql", query);
An error occurred at line: 167 in the jsp file: /Test.jsp
ARQ cannot be resolved
164: "select DISTINCT ?location where { ?s rdf:type dbpedia-owl:Museum . ?s dbpprop:location ?l. ?l dbpprop:nativeName ?location. ?l dbpprop:pushpinMap ?country FILTER(?country=\"Egypt\"@en && LANG(?location)='en')}";
165:
166: Query query = QueryFactory.create(sparqlQueryString2);
167: ARQ.getContext().setTrue(ARQ.useSAX);
168:
169: QueryExecution qexec = QueryExecutionFactory.sparqlService("http://DBpedia.org/sparql", query);
170:
An error occurred at line: 167 in the jsp file: /Test.jsp
ARQ.useSAX cannot be resolved to a type
164: "select DISTINCT ?location where { ?s rdf:type dbpedia-owl:Museum . ?s dbpprop:location ?l. ?l dbpprop:nativeName ?location. ?l dbpprop:pushpinMap ?country FILTER(?country=\"Egypt\"@en && LANG(?location)='en')}";
165:
166: Query query = QueryFactory.create(sparqlQueryString2);
167: ARQ.getContext().setTrue(ARQ.useSAX);
168:
169: QueryExecution qexec = QueryExecutionFactory.sparqlService("http://DBpedia.org/sparql", query);
170:
An error occurred at line: 169 in the jsp file: /Test.jsp
QueryExecution cannot be resolved to a type
166: Query query = QueryFactory.create(sparqlQueryString2);
167: ARQ.getContext().setTrue(ARQ.useSAX);
168:
169: QueryExecution qexec = QueryExecutionFactory.sparqlService("http://DBpedia.org/sparql", query);
170:
171: ResultSet results = qexec.execSelect();
172:
An error occurred at line: 169 in the jsp file: /Test.jsp
QueryExecutionFactory cannot be resolved
166: Query query = QueryFactory.create(sparqlQueryString2);
167: ARQ.getContext().setTrue(ARQ.useSAX);
168:
169: QueryExecution qexec = QueryExecutionFactory.sparqlService("http://DBpedia.org/sparql", query);
170:
171: ResultSet results = qexec.execSelect();
172:
An error occurred at line: 171 in the jsp file: /Test.jsp
ResultSet cannot be resolved to a type
168:
169: QueryExecution qexec = QueryExecutionFactory.sparqlService("http://DBpedia.org/sparql", query);
170:
171: ResultSet results = qexec.execSelect();
172:
173: while (results.hasNext()) {
174: QuerySolution soln = results.nextSolution();
An error occurred at line: 174 in the jsp file: /Test.jsp
QuerySolution cannot be resolved to a type
171: ResultSet results = qexec.execSelect();
172:
173: while (results.hasNext()) {
174: QuerySolution soln = results.nextSolution();
175:
176:
177: String rslt = soln.get("?location");
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:468)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
the test.jsp code is :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page import="com.hp.hpl.jena.query.Query"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" import="java.io.*, java.net.*, com.hp.hpl.jena.query.ARQ.*, com.hp.hpl.jena.query.Query.*, com.hp.hpl.jena.query.QueryExecution.*, com.hp.hpl.jena.query.QueryExecutionFactory.*, com.hp.hpl.jena.query.QueryFactory.*, com.hp.hpl.jena.query.QuerySolution.*, com.hp.hpl.jena.query.ResultSet.*"%>
<select id="Country" class="Select" onChange="this.form.submit()">
<%
try
{
String sparqlQueryString2 ="PREFIX dbpprop: <http://dbpedia.org/property/>"+
"PREFIX dbpedia: <http://dbpedia.org/resource/>"+
"PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>"+
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"+
"select DISTINCT ?location where { ?s rdf:type dbpedia-owl:Museum . ?s dbpprop:location ?l. ?l dbpprop:nativeName ?location. ?l dbpprop:pushpinMap ?country FILTER(?country=\"Egypt\"@en && LANG(?location)='en')}";
Query query = QueryFactory.create(sparqlQueryString2);
ARQ.getContext().setTrue(ARQ.useSAX);
QueryExecution qexec = QueryExecutionFactory.sparqlService("http://DBpedia.org/sparql", query);
ResultSet results = qexec.execSelect();
while (results.hasNext()) {
QuerySolution soln = results.nextSolution();
String rslt = soln.get("?location");
%>
<option value="<%=rslt%>"> <%=rslt%> </option>
<%
}
qexec.close();
}
catch (Exception ex)
{
System.out.print(ex.toString());
}
%>
</select>
note:
I was put jena library in the build path of the project