solr定時更新索引遇到的問題(SolrDataImportProperties Error loading DataImportScheduler properties java.lang.Null。本站提示廣大學習愛好者:(solr定時更新索引遇到的問題(SolrDataImportProperties Error loading DataImportScheduler properties java.lang.Null)文章只能為提供參考,不一定能成為您想要的結果。以下是solr定時更新索引遇到的問題(SolrDataImportProperties Error loading DataImportScheduler properties java.lang.Null正文
問題描繪
報如下錯誤,很顯然,問題緣由:空指針異常;
ERROR (localhost-startStop-1) [ ] o.a.s.h.d.s.SolrDataImportProperties Error loading DataImportScheduler properties
java.lang.NullPointerException
at sun.nio.fs.UnixPath.normalizeAndCheck(UnixPath.java:77)
at sun.nio.fs.UnixPath.<init>(UnixPath.java:71)
at sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:281)
at java.nio.file.Paths.get(Paths.java:84)
at org.apache.solr.core.SolrResourceLoader.<init>(SolrResourceLoader.java:151)
at org.apache.solr.handler.dataimport.scheduler.SolrDataImportProperties.loadProperties(SolrDataImportProperties.java:36)
at org.apache.solr.handler.dataimport.scheduler.BaseTimerTask.reloadParams(BaseTimerTask.java:57)
at org.apache.solr.handler.dataimport.scheduler.BaseTimerTask.<init>(BaseTimerTask.java:39)
at org.apache.solr.handler.dataimport.scheduler.DeltaImportHTTPPostScheduler.<init>(DeltaImportHTTPPostScheduler.java:20)
at org.apache.solr.handler.dataimport.scheduler.ApplicationListener.contextInitialized(ApplicationListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4716)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5178)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1107)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1841)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
詳細緣由:定時更新運用的jar包apache-solr-dataimportscheduler-1.1.jar是網上找的,仿佛版本更不上了,反編譯一下,問題出在SolrDataImportProperties類的36行,如下標紅地位:
public void loadProperties(boolean force) {
try {
SolrResourceLoader loader = new SolrResourceLoader(null);
logger.info("Instance dir = " + loader.getInstanceDir());
String configDir = loader.getConfigDir();
configDir = SolrResourceLoader.normalizeDir(configDir);
我的solr版本是5.5.3,找到org.apache.solr.core.SolrResourceLoader,檢查其結構辦法,有四個,我們運用的是public SolrResourceLoader(Path instanceDir),由於傳入的instanceDir為null報錯(詳細外部代碼就沒調試出來了):
public SolrResourceLoader() {
this(locateSolrHome(), null, null);
}
public SolrResourceLoader(Path instanceDir, ClassLoader parent)
{
this(instanceDir, parent, null);
}
public SolrResourceLoader(Path instanceDir) {
this(instanceDir, null, null);
}
public SolrResourceLoader(Path instanceDir, ClassLoader parent, Properties coreProperties)
{
if (instanceDir == null) {
...
如何處理
修正apache-solr-dataimportscheduler-1.1代碼,重新打包,經測試,定時增量更新和全量更新功用正常。
附件(修正後的jar包)
下載鏈接:
http://files.cnblogs.com/files/chenpi/solr-dataimportscheduler-1.1-source.zip