記錄一下在servlet裏調用lucene時遇到的問題

做爲一個沒有系統學過java和javaweb就直接上手作東西的程序猿,有時遇到的額問題真的讓我很無解呀,今天在servlet裏調用一個lucene程序,各類出錯,把那個程序單獨拿出來運行時一切正常,在servlet裏調用時就出錯,不只出錯連個人web項目的主頁都已經訪問不鳥了,糾結了一下午,我試着一條一條語句的註釋掉執行,試圖找出究竟是那句引發的問題,仍是失敗了。最後,在overstackflow上找到了答案,http://stackoverflow.com/questions/14638696/servlet-exception-with-lucene-demo-class, java

上面說到了, web

java.lang.ClassNotFoundException is related to Java Classpath. ClassNotFoundException comes when JVM tries to load a class at runtime dynamically and if that class is not found in classpath it throwsjava.lang.ClassNotFoundException. app

As, you are using third party API called Apache Lucene, you need to place all required jar files to application classpath. eclipse

For a web application default classpath is /WEB-INF/lib directory under webapp or WebContent directory. webapp

Copy all required jar files there, eclipse takes care everything rest. ui

看完以後果斷把lucene相關的包拷貝到下,問題隨之解決,哈哈哈哈。 spa

相關文章
相關標籤/搜索