eclipse jena和tomcat查询

时间:2012-11-05 03:39:53

标签: eclipse servlets sparql jena

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

     

mensajeLajejecióndelServletlanzóunaexppción

     

descripciónElservidorencontróunerror interno que hizo que no   pudiera rellenar este requerimiento。

     

excepción

     

javax.servlet.ServletException:LaejecucióndelServletlanzóuna   excepció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)causa   raí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。

1 个答案:

答案 0 :(得分:0)

  

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

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