gpt4 book ai didi

java - 在嵌入式 Jetty 中运行 Solr 时出现异常

转载 作者:行者123 更新时间:2023-12-01 14:09:28 26 4
gpt4 key购买 nike

我在嵌入式 Jetty 中运行 Solr 4.4.0,但出现以下异常:

3859 [coreLoadExecutor-3-thread-1] ERROR org.apache.solr.core.CoreContainer - null:java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:266)
at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:433)
at org.apache.solr.core.SolrResourceLoader.newInstance(SolrResourceLoader.java:543)
at org.apache.solr.schema.FieldTypePluginLoader$3.create(FieldTypePluginLoader.java:382)
at org.apache.solr.schema.FieldTypePluginLoader$3.create(FieldTypePluginLoader.java:376)
at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:151)
at org.apache.solr.schema.FieldTypePluginLoader.readAnalyzer(FieldTypePluginLoader.java:400)
at org.apache.solr.schema.FieldTypePluginLoader.create(FieldTypePluginLoader.java:86)
at org.apache.solr.schema.FieldTypePluginLoader.create(FieldTypePluginLoader.java:43)
at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:151)
at org.apache.solr.schema.IndexSchema.readSchema(IndexSchema.java:467)
at org.apache.solr.schema.IndexSchema.<init>(IndexSchema.java:164)
at org.apache.solr.schema.IndexSchemaFactory.create(IndexSchemaFactory.java:55)
at org.apache.solr.schema.IndexSchemaFactory.buildIndexSchema(IndexSchemaFactory.java:69)
at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:619)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:657)
at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:364)
at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:356)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ClassCastException: class org.apache.lucene.analysis.ar.ArabicNormalizationFilterFactory
at java.lang.Class.asSubclass(Class.java:3046)
at org.apache.lucene.util.SPIClassIterator.next(SPIClassIterator.java:137)
at org.apache.lucene.analysis.util.AnalysisSPILoader.reload(AnalysisSPILoader.java:79)
at org.apache.lucene.analysis.util.AnalysisSPILoader.<init>(AnalysisSPILoader.java:60)
at org.apache.lucene.analysis.util.AnalysisSPILoader.<init>(AnalysisSPILoader.java:49)
at org.apache.lucene.analysis.util.TokenFilterFactory.<clinit>(TokenFilterFactory.java:31)
... 27 more

这是 Java 代码中的主要方法:

public static void main(String[] args) throws Exception
{
Server server = new Server(8083);
WebAppContext webapp = new WebAppContext();
webapp.setContextPath("/");
webapp.setWar("C:\\Solr\\solr-4.4.0.war");
server.setHandler(webapp);
System.setProperty("solr.solr.home", "C:\\solr");
server.start();
server.join();
}

我们使用在 schema.xml 中声明的自定义字段类型,如下所示(无需此字段类型即可工作):

<fieldType name="zyfield" class="solr.TextField" positionIncrementGap="0" >
<analyzer type="index">
<!--<tokenizer class="solr.PatternTokenizerFactory" pattern="([\.0-9]+|@??[&amp;'a-zA-Z_0-9-]+(\.(net|ie|uk|com|txt))?)" group="1"/>-->
<tokenizer class="solr.PatternTokenizerFactory" pattern="(www|@??[-0-9\p{L}\p{Sc}]+?[-'0-9.\p{L}\p{Sc}&amp;]*[-0-9\p{L}]+?|[-0-9\p{L}\p{Sc}]+?)" group="1"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="ie.solrplugin.KDelimiterFilterFactory"/>
<filter class="ie.solrplugin.JunkTokenFilterFactory"/>
<filter class="solr.ASCIIFoldingFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.PatternTokenizerFactory" pattern="(www|@??[-0-9\p{L}\p{Sc}]+?[-'0-9.\p{L}\p{Sc}&amp;]*[-0-9\p{L}]+?|[-0-9\p{L}\p{Sc}]+?)" group="1"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="ie.solrplugin.KDelimiterFilterFactory"/>
<filter class="ie.solrplugin.JunkTokenFilterFactory"/>
<filter class="solr.ASCIIFoldingFilterFactory"/>
</analyzer>

最佳答案

您可能会遇到运行 main 方法的项目的类路径与所有 WebApp 存在的类加载器隔离之间的复杂性。

尝试添加此内容以告诉 WebAppContext 使用父类加载器而不是 WebApp 自己的类加载器。

public static void main(String[] args) throws Exception
{
Server server = new Server(8083);
WebAppContext webapp = new WebAppContext();
webapp.setContextPath("/");
webapp.setWar("C:\\Solr\\solr-4.4.0.war");
webapp.setParentLoaderPriority(true); // <-- this line
server.setHandler(webapp);
System.setProperty("solr.solr.home", "C:\\solr");
server.start();
server.join();
}

关于java - 在嵌入式 Jetty 中运行 Solr 时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18641140/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com