2011-03-26 49 views
2

難道而在Java Web應用程序使用耶拿...請請幫助我..中的Java Web應用耶拿阿比...未知異常

這裏是我的servlet代碼沒有人遇到這個異常

package com.mycompany.servlet; 

import java.io.IOException; 
import java.util.Iterator; 

import javax.servlet.RequestDispatcher; 
import javax.servlet.ServletContext; 
import javax.servlet.ServletException; 
import javax.servlet.annotation.WebServlet; 
import javax.servlet.http.HttpServlet; 
import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 



import com.hp.hpl.jena.query.QueryExecution; 
import com.hp.hpl.jena.query.QueryExecutionFactory; 
import com.hp.hpl.jena.query.QueryFactory; 
import com.hp.hpl.jena.query.ResultSet; 

import com.hp.hpl.jena.rdf.model.ModelFactory; 

import com.hp.hpl.jena.ontology.*; 


/** 
* Servlet implementation class GreetingServlet 
*/ 
@WebServlet("/GreetingServlet") 
public class GreetingServlet extends HttpServlet { 
    private static final long serialVersionUID = 1L; 

    /** 
    * @see HttpServlet#HttpServlet() 
    */ 
    public GreetingServlet() { 
     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 SOURCE ="file:E:\\healthcare.owl"; 

     OntModel base = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); 
     base.read(SOURCE); 


     for (Iterator<OntClass> i = base.listClasses(); i.hasNext();) 
     { 

     OntClass c = i.next();    

     //System.out.println("Class" + c.getLocalName()); 

     } 
    } 

    } 

例外是 HTTP狀態500 -


類型異常報告

消息

description The server encountered an internal error() that prevented it from fulfilling this request. 

例外

javax.servlet.ServletException: Error instantiating servlet class com.mycompany.servlet.GreetingServlet 
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498) 
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) 
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562) 
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394) 
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243) 
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188) 
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166) 
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) 
    java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) 
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    java.lang.Thread.run(Unknown Source) 

根源

java.lang.NoClassDefFoundError: com/hp/hpl/jena/rdf/model/Model 
    java.lang.Class.getDeclaredConstructors0(Native Method) 
    java.lang.Class.privateGetDeclaredConstructors(Unknown Source) 
    java.lang.Class.getConstructor0(Unknown Source) 
    java.lang.Class.newInstance0(Unknown Source) 
    java.lang.Class.newInstance(Unknown Source) 
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498) 
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) 
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562) 
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394) 
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243) 
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188) 
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166) 
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) 
    java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) 
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    java.lang.Thread.run(Unknown Source) 

根源

java.lang.ClassNotFoundException: com.hp.hpl.jena.rdf.model.Model 
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676) 
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521) 
    java.lang.Class.getDeclaredConstructors0(Native Method) 
    java.lang.Class.privateGetDeclaredConstructors(Unknown Source) 
    java.lang.Class.getConstructor0(Unknown Source) 
    java.lang.Class.newInstance0(Unknown Source) 
    java.lang.Class.newInstance(Unknown Source) 
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498) 
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) 
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562) 
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394) 
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243) 
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188) 
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166) 
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) 
    java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) 
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    java.lang.Thread.run(Unknown Source) 

音符的根本原因的完整堆棧跟蹤是在Apache Tomcat的可用/ 7。 0.11個日誌。


回答

3
root cause 

java.lang.ClassNotFoundException: com.hp.hpl.jena.rdf.model.Model 

這意味着,tomcat的找不到耶拿庫。確保你有正確的地方所有正確的罐子。

+0

更改代碼將不會執行任何操作(除非您刪除了Jena依賴關係)。您需要查看該框架的文檔,瞭解您需要在部署中包含哪些jar文件。 – Mat 2011-03-26 16:45:24

+0

我已經將所有jena jar文件放在應用程序構建路徑中。但異常仍然呈現.. whatelse我需要 – 2011-03-27 10:58:54

+0

你需要這些罐子的地方,阿帕奇可以找到他們。他們必須被捆綁到你部署的東西中,或者放在tomcat目錄中的某個地方。 – Mat 2011-03-27 11:00:51

0

你需要每個*.jar文件從$JENA/lib複製(其中$JENA爲您安裝耶拿的本地安裝到該目錄中)到WEB-INF/lib目錄你的servlet應用程序。

0

剛纔複製的構建路徑項目到tomcat的lib目錄中聲明的耶拿罐子,在我的情況下,它位於

C:\ Apache軟件基金會\ Tomcat的6.0 \ lib中

+0

我面臨同樣的問題,這是我的解決方案。 – Khouloud 2015-08-20 21:02:35

+0

我覺得把tomcat安裝中的servlet依賴關係搞糊塗了,但確定這是個答案。 – mpromonet 2015-08-21 21:32:06

+0

它不會在我的情況下工作,通過將它們添加到web-INF/lib,所以我只是製作了tomcat直接訪問的jar,這就是爲什麼我遵循這個解決方案。 – Khouloud 2015-08-22 00:55:35