0
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问题:

输入异常通知

mensaje La ejecución del Servlet lanzó una excepción

描述 El servidor encontró un error interno que hizo que no pudiera rellenar este requerimiento。

例外

javax.servlet.ServletException: La ejecución del Servlet lanzó una excepción causa raí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) 原因

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) 注意Apache Tomcat/6.0.36 的完整原因错误 se encuentra en los archivos de diario de diario。

4

1 回答 1

0

java.lang.NoClassDefFoundError: com/hp/hpl/jena/rdf/model/ModelFactory rdf.doPost(rdf.java:55)

jena jar 不在 webapp 的运行时类路径上。

于 2012-11-05T12:10:17.233 回答