本文介绍了使用Eclipse IDE的Jena无法为JSP编译类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!



我在JEE动态网络项目中遇到问题。我尝试在项目中使用jena库来检索indx.jsp中的sparql查询结果但是在运行时发生以下问题:



HTTP状态500 - 无法JSP的编译类:



---------------------- -------------------------------------------------- --------



类型异常​​报告



消息无法为JSP编译类:



描述服务器遇到内部错误,无法完成此请求。



exception



org.apache.jasper.JasperException:无法为JSP编译类:

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:            //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)



test.jsp代码是:


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);
           //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>







注意:

我把jena库放在项目的构建路径中




note:
I was put jena library in the build path of the project

推荐答案


这篇关于使用Eclipse IDE的Jena无法为JSP编译类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 00:43