import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.util.FileManager;
import com.hp.hpl.jena.sparql.*;
import java.io.InputStream;
import com.hp.hpl.jena.query.*;
import com.hp.hpl.jena.util.FileManager;
import com.hp.hpl.jena.ontology.*;
/**
* Servlet implementation class rdf
*/
public class rdf extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public rdf() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String inputFileName = "/home/jarboox/Documentos/Eclipse/workspace/Sparql/src/tres.rdf";
try {
//create the reasoning model using the base
OntModel inf = ModelFactory.createOntologyModel();
// use the FileManager to find the input file
InputStream in = FileManager.get().open(inputFileName);
if (in == null) {
throw new IllegalArgumentException("File: " + inputFileName + " not found");
}
inf.read(in, "");
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
Tomcatの問題:
InformedeExcepciónと入力します
mensajeLaejecucióndelServletlanzóunaexcepción
説明Elservidorencontróunerrorinternoque hizo que no pudiera rellenaresterequerimiento。
エクセプシオン
javax.servlet.ServletException:LaejecucióndelServletlanzóunaexcepcióncausaraíz
java.lang.NoClassDefFoundError:com / hp / hpl / jena / rdf / model / ModelFactory rdf.doPost(rdf.java:55)javax.servlet.http.HttpServlet.service(HttpServlet.java:637)javax.servlet.http .HttpServlet.service(HttpServlet.java:717)causaraíz
java.lang.ClassNotFoundException:com.hp.hpl.jena.rdf.model.ModelFactory org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader .java:1526)rdf.doPost(rdf.java:55)javax.servlet.http.HttpServlet.service(HttpServlet.java:637)javax.servlet.http.HttpServlet.service(HttpServlet.java:717)nota La traza completa de la causa de este error se encuentra en los archivos de diario de Apache Tomcat/6.0.36。