3

Can't figure out what is causing ' 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'

Any help would be appreciated

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 deployment folder path 'C:\JBAS\modules\org\apache\lucene\main' and directory contents enter image description here

jboss-deployment-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 build file segment

<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" />
lego.warrior
  • 342
  • 3
  • 16

3 Answers3

2

Please add following file in

Folder : META-INF/services/

File :org.apache.lucene.codecs.Codec

Text :org.apache.lucene.codecs.lucene54.Lucene54Codec

Please review the solution with detailed description at https://anwaarlabs.wordpress.com/2017/02/25/lucene-an-spi-class-of-type-org-apache-lucene-codecs-codec-with-name-does-not-exist/

This solution is defined for Lucene5.4 it also works for Lucene 4.2. Thanks

Digital Alchemist
  • 2,324
  • 1
  • 15
  • 17
1

I find something about this. Hope there would be helpful though I use lucene 4.10.2.

The codecs are configured in 'org.apache.lucene.codecs.Codec'. I looked into 'lucene-core-4.10.2.jar' and there is such a file 'META-INF\services\org.apache.lucene.codecs.Codec'. So you can put the class name into configuration file and lucene would find it. However, you don't need extract the jar file, add it and re-package the jar. Just create a new file with the same directory structure, that is, 'META-INF\services\org.apache.lucene.codecs.Codec' into java's classpath, e.g., 'target/classes' directory, and java would find all codec configuration file and load them.

seven7e
  • 798
  • 1
  • 8
  • 19
  • i'll try this out, and let you know how it goes. might take a few days as i'm working on a different rqm these days. :) – lego.warrior Jul 07 '15 at 09:52
  • In my luce-core the lucene.Codes.codec file already exists and it has a path to org.apache.lucene.codecs.lucene42.Lucene42Codec The lucene42Codec class file is also present. Maybe i understood your answer wrong. If you have the time, can you elaborate a bit more. – lego.warrior Jul 08 '15 at 10:59
  • There seems to be no misunderstanding. It's wired, your problem might be different from mine. You might have to debug the project (I use IDEA) with putting a breakpoint on `NamedSPILoader::reload` function by yourself to see how codecs are loaded. It seems that nothing is loaded from the error message because of the empty list in `The current classpath supports the following names: []`. – seven7e Jul 09 '15 at 08:56
  • @lego.warrior Maybe you need to check the content the ` META-INF/services/org.apache.lucene.codecs.Codec` file to ensure the classname you need is in this file. If not, it is needed to put the classname `org.apache.lucene.codecs.lucene42.Lucene42Codec` in the codec file. – seven7e Jul 09 '15 at 09:00
  • ` META-INF/services/org.apache.lucene.codecs.Codec` file in my lucene-core.jar has a statement in it "org.apache.lucene.codecs.lucene42.Lucene42Codec". I will recheck, thou. – lego.warrior Jul 09 '15 at 09:05
0

sometimes it happens when you create an index using a version of lucene, or your index is corrupted. try deleting your entire index and re-indexing.

Rafael Sanches
  • 1,823
  • 21
  • 28