2015-04-23 31 views
3

無法確定是什麼原因導致'名爲'Lucene42'的SPI類型的org.apache.lucene.codecs.Codec不存在。您需要添加相應的JAR文件支持這一SPI到classpath '什麼原因導致錯誤'類型爲lucene.codecs.Codec名稱的SPI類'Lucene42'

任何幫助,將不勝感激

java.lang.IllegalArgumentException: A SPI class of type org.apache.lucene.codecs.Codec with name 'Lucene42' does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath.The current classpath supports the following names: [] 
org.apache.lucene.util.NamedSPILoader.lookup(NamedSPILoader.java:104) 
org.apache.lucene.codecs.Codec.forName(Codec.java:95) 
org.apache.lucene.codecs.Codec.<clinit>(Codec.java:122) 
org.apache.lucene.index.LiveIndexWriterConfig.<init>(LiveIndexWriterConfig.java:118) 
org.apache.lucene.index.IndexWriterConfig.<init>(IndexWriterConfig.java:145) 
com.damn.fr.rr.rent.getResukt(Man.java:404) 
com.damn.fr.rr.handler.pg.setResult(pg.java:103) 
com.damn.fr.rr.cmd.del.execute(del.java:19) 
com.damn.fr.rr.servlet.PublicController.doPost(controller.java:199) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:754) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:847) 

JBoss部署文件夾路徑' C:\ JBAS \模塊\組織\阿帕奇\ lucene的\主「和目錄內容 enter image description here

JBoss的部署,structure.xml

<sub-deployment name="damn.jar"> 
    <dependencies> 
     <module name="org.apache.commons.fileupload" /> 
     <module name="org.apache.commons.io" /> 
     <module name="org.apache.commons.lang3" /> 
     <module name="org.apache.commons.validator" /> 
     <module name="org.apache.lucene" /> 
     <module name="net.sf.jasperreports" /> 
     <module name="com.google.gson" /> 

    </dependencies> 
</sub-deployment> 

module.xml

<module xmlns="urn:jboss:module:1.0" name="org.apache.lucene"> 
<resources> 
<resource-root path="lucene-analyzers-common-4.2.0.jar"/> 
<resource-root path="lucene-core-4.2.0.jar"/> 
<resource-root path="lucene-queryparser-4.2.0.jar"/> 
<resource-root path="lucene-codecs-4.2.0.jar"/> 
</resources> 

<dependencies> 
</dependencies> 

Ant構建文件段

<pathelement path="${thirdPartyDir}/lucene-analyzers-common-4.2.0.jar" /> 
<pathelement path="${thirdPartyDir}/lucene-codecs-4.2.0.jar" /> 
<pathelement path="${thirdPartyDir}/lucene-queryparser- 4.2.0.jar" /> 
<pathelement path="${thirdPartyDir}/lucene-core-4.2-SNAPSHOT.jar" /> 
+0

嗨,李,我使用lucene時遇到了類似的錯誤,你有沒有找到解決辦法? – nanoix9

+0

@ nanoix9,還沒有。如果我這樣做,我會讓你知道的。希望你也能做到這一點:) –

回答

1

我找到這個。希望這會有幫助,雖然我使用的是lucene 4.10.2。

編解碼器在'org.apache.lucene.codecs.Codec'中配置。我看着'lucene-core-4.10.2.jar',並且有一個'META-INF \ services \ org.apache.lucene.codecs.Codec'文件。所以你可以把類名放到配置文件中,lucene會找到它。但是,您不需要解壓縮該jar文件,將其添加並重新打包該jar。只需創建一個具有相同目錄結構的新文件,即'META-INF \ services \ org.apache.lucene.codecs.Codec'到java的類路徑中,例如'target/classes'目錄,java將找到所有編解碼器配置文件並加載它們。

+0

我會試試這個,並讓你知道它是怎麼回事。可能需要幾天,因爲我現在在不同的rqm上工作。 :) –

+0

在我的luce-core中,lucene.Codes.codec文件已經存在,並且它有一個路徑到org.apache.lucene.codecs.lucene42.Lucene42Codec lucene42Codec類文件也存在。 也許我明白你的答案錯了。如果你有時間,你能否詳細說明一下。 –

+0

似乎沒有誤解。它是有線的,你的問題可能與我的不同。您可能需要調試項目(我使用IDEA),並在自己的'NamedSPILoader :: reload'函數上放置一個斷點以查看編解碼器是如何加載的。似乎沒有任何東西從錯誤消息中加載,因爲'當前類路徑支持以下名稱:[]''。 – nanoix9

0

有時發生在使用lucene版本創建索引或索引損壞時。嘗試刪除您的整個索引並重新編制索引。

相關問題