[英]An SPI class of type org.apache.lucene.codecs.Codec with name 'Lucene54' does not exist
With lucene-core-5.5.2 i am facing problem a in weblogic server. 使用lucene-core-5.5.2,我在weblogic服务器中遇到问题。 standalone search application works but when i deploy as WEB APP it is failing with below error 独立搜索应用程序可以工作,但是当我作为WEB APP部署时,它失败并出现以下错误
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 我尝试在classes/
下创建文件夹结构,因为META-INF/services/
添加了来自lucene-core-5.5.2.jar META-INF\\services\\
所有文件lucene-core-5.5.2.jar META-INF\\services\\
目录也创建了META-INF\\services\\
jar文件并添加到类路径中但它无法识别加载SPI的META-INF/services
Any help would be really appreciated. 任何帮助将非常感激。
Please add following file in 请添加以下文件
Folder : META-INF/services/
文件夹: META-INF/services/
File : org.apache.lucene.codecs.Codec
文件: org.apache.lucene.codecs.Codec
Text : org.apache.lucene.codecs.lucene54.Lucene54Codec
文字: 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/ 请查看解决方案,详细说明请访问https://anwaarlabs.wordpress.com/2017/02/25/lucene-an-spi-class-of-type-org-apache-lucene-codecs-codec-with-name-不存在/
its is fixed i added lucene jars in weblogic app server classpath and it is working as expected. 它是固定的我在weblogic app server classpath中添加了lucene jar并且它按预期工作。 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 我不知道为什么它不是从我的应用程序lib文件夹中检测到它也在类路径上,但看起来像某种程度上SPI需要jar和appA服务器类路径上的META-INF
I got this building with gradle using a proposed solution to build a "fat jar" (executable jar containing all dependent jars) here . 我用一个提出的解决方案,以建立一个“胖罐子”(包含所有依赖jar可执行的JAR)得到这个建筑gradle这个位置 。
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. 但它不起作用:我得到了与Lucene一样的模糊错误,但是在测试或构建或正常运行时,仅在构建胖罐时没有。
My solution was to use shadow jar : code from gradle.build: 我的解决方案是使用shadow jar :来自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
}
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 此外,我还在依赖项标记的顶部添加了lucene-core依赖项
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>5.5.0</version>
</dependency>
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. 确保项目中包含的lucene jar与错误中提到的lucene编解码器的版本相同。 Eg if the error states LuceneCodec62 then you should have lucene-6.xx jar included in your project. 例如,如果错误表明LuceneCodec62,那么你的项目中应该包含lucene-6.xx jar。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.