An SPI class of type org.apache.lucene.codecs.Codec with name 'Lucene54' does not exist
Asked Answered
J

6

10

With lucene-core-5.5.2 i am facing problem a in weblogic server. standalone search application works but when i deploy as WEB APP it is failing with below error

Exception type is 'java.lang.ExceptionInInitializerError'. Runtime error: java.lang.IllegalArgumentException: An SPI class of type org.apache.lucene.codecs.Codec with name 'Lucene54' does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath. The current classpath supports the following names: []

I tried creating folder structure under classes/ as META-INF/services/ added all files from lucene-core-5.5.2.jar META-INF\services\ directory also created jar file for META-INF\services\ and added in classpath but it doesn't recognize META-INF/services to load SPI

Any help would be really appreciated.

Jughead answered 13/7, 2016 at 20:55 Comment(0)
C
3

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/

Chrisoula answered 25/2, 2017 at 21:51 Comment(3)
Thanks ! This saved my time.Diameter
Didn't work for me. Using Lucene 6.2 but confusingly got an error stacktrace which mentioned both 6.2 and 5.0: "Cannot instantiate SPI class: org.apache.lucene.codecs.lucene62.Lucene62Codec" ... then "An SPI class of type org.apache.lucene.codecs.PostingsFormat with name 'Lucene50' does not exist"... I tried your solution with many permutations, nothing worked. See my sort of "workaround" answer.Xebec
@mikerodent i dont get error stacktrace which mentioned both 6.2 and 5.0Chrisoula
X
1

I got this building with gradle using a proposed solution to build a "fat jar" (executable jar containing all dependent jars) here.

But it didn't work: I got this obscure error to do with Lucene, but not when testing or building or running normally, only when building a fat jar.

My solution was to use shadow jar: code from gradle.build:

buildscript {
    repositories { jcenter() }
    dependencies { // fatjar
        classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4' }
}
apply plugin: 'com.github.johnrengelman.shadow'
shadowJar {
    baseName = project.name
    classifier = null
    version = project.version
}
Xebec answered 10/6, 2017 at 18:24 Comment(2)
I'm also using the shadow plugin, and needed this setting to make it work: ``` shadowJar { mergeServiceFiles() } ``` Based on this github comment: github.com/johnrengelman/shadow/issues/…Snowonthemountain
shadowJar { mergeServiceFiles() } It helped, may be the answer can be updated with thisBeaver
U
1

I added the below code into configuration tags

<transformers>
    <transformer  implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
        <resource>META-INF/services/org.apache.lucene.codecs.Codec</resource>
        <resource>META-INF/services/org.apache.lucene.codecs.PostingsFormat</resource>
    </transformer>
</transformers>

And also I add lucene-core dependency at the top of the dependencies tag

<dependency>
    <groupId>org.apache.lucene</groupId>
    <artifactId>lucene-core</artifactId>
    <version>5.5.0</version>
</dependency>
Unmeant answered 13/11, 2017 at 13:28 Comment(0)
J
0

its is fixed i added lucene jars in weblogic app server classpath and it is working as expected. i dont know why it is not detecting from my applications lib folder as its also on class path but looks like somehow SPI needs jars and META-INF on app servers classpath

Jughead answered 14/7, 2016 at 18:53 Comment(0)
W
0

Make sure that the lucene jar that you have included in your project is of the same version as that of lucene codec mentioned in error. E.g. if the error states LuceneCodec62 then you should have lucene-6.x.x jar included in your project.

Wagoner answered 15/6, 2019 at 8:57 Comment(0)
C
0

I just added the appropriate codec jar as a dependency.

<dependency>
   <groupId>org.apache.lucene</groupId>
    <artifactId>lucene-codecs</artifactId>
    <version>7.2.0</version>
    <scope>test</scope>
</dependency>
Chlodwig answered 26/9, 2023 at 18:16 Comment(1)
I had added the SPI configuration files, and gotten past the codec, but ran into additional issues with SPI. I thought I had all the classes accounted for, but could not get it working. I added the codec jar and removed all the resource files. Seems easier. But I am only using the standard implementations.Chlodwig

© 2022 - 2024 — McMap. All rights reserved.