Click here to Skip to main content
15,904,155 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
Java
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:            //Executing SPARQL Query and pointing to the DBpedia SPARQL Endpoint 
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:            //Executing SPARQL Query and pointing to the DBpedia SPARQL Endpoint 
169:             QueryExecution qexec = QueryExecutionFactory.sparqlService("http://DBpedia.org/sparql", query);
170:            //Retrieving the SPARQL Query results


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:            //Executing SPARQL Query and pointing to the DBpedia SPARQL Endpoint 
169:             QueryExecution qexec = QueryExecutionFactory.sparqlService("http://DBpedia.org/sparql", query);
170:            //Retrieving the SPARQL Query results


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:            //Executing SPARQL Query and pointing to the DBpedia SPARQL Endpoint 
169:             QueryExecution qexec = QueryExecutionFactory.sparqlService("http://DBpedia.org/sparql", query);
170:            //Retrieving the SPARQL Query results
171:             ResultSet results = qexec.execSelect();
172:            //Iterating over the SPARQL Query results


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:            //Executing SPARQL Query and pointing to the DBpedia SPARQL Endpoint 
169:             QueryExecution qexec = QueryExecutionFactory.sparqlService("http://DBpedia.org/sparql", query);
170:            //Retrieving the SPARQL Query results
171:             ResultSet results = qexec.execSelect();
172:            //Iterating over the SPARQL Query results


An error occurred at line: 171 in the jsp file: /Test.jsp
ResultSet cannot be resolved to a type
168:            //Executing SPARQL Query and pointing to the DBpedia SPARQL Endpoint 
169:             QueryExecution qexec = QueryExecutionFactory.sparqlService("http://DBpedia.org/sparql", query);
170:            //Retrieving the SPARQL Query results
171:             ResultSet results = qexec.execSelect();
172:            //Iterating over the SPARQL Query results
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:            //Iterating over the SPARQL Query results
173:             while (results.hasNext()) {
174:                 QuerySolution soln = results.nextSolution();
175:                 //Printing DBpedia entries' abstract.
176:               //  System.out.println(soln.get("?location")); 
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 :
XML
<!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);
           //Executing SPARQL Query and pointing to the DBpedia SPARQL Endpoint
            QueryExecution qexec = QueryExecutionFactory.sparqlService("http://DBpedia.org/sparql", query);
           //Retrieving the SPARQL Query results
            ResultSet results = qexec.execSelect();
           //Iterating over the SPARQL Query results
            while (results.hasNext()) {
                QuerySolution soln = results.nextSolution();
                //Printing DBpedia entries' abstract.
              //  System.out.println(soln.get("?location"));
                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
Posted
Updated 19-Jun-13 1:37am
v3

1 solution

Actually your import statement are wrong .For an example QueryFactory is class , not a package. So your import statement should be :

import="com.hp.hpl.jena.query.QueryFactory"

instead of

import="com.hp.hpl.jena.query.QueryFactory.*"

Hence the same reason for the rest of the class.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900