我们正在尝试从Solr 3.6.2升级到Solr 4.2.1,并且在data-config.xml中使用solrcore.properties中的属性时遇到问题。
使用Solr 3.6.2,我们可以直接在data-config.xml中的solrcore.properties中使用属性,如:
<dataSource driver="${jdbc.driver}"
url="jdbc:mysql://${jdbc.host}:${jdbc.port}/${db.name}"
user="${jdbc.username}"
password="${jdbc.password}"
batchSize="-1" />
现在找不到这些属性,因此当我调用dataimport时会抛出此异常:
Apr 26, 2013 11:10:58 AM org.apache.solr.common.SolrException log
SEVERE: Full Import failed:java.lang.RuntimeException: java.lang.RuntimeException: org.apache.solr.handler.dataimport.DataImportHandlerException: Could not load driver: Processing Document # 1
at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:266)
at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:422)
at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:487)
at org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:468)
Caused by: java.lang.RuntimeException: org.apache.solr.handler.dataimport.DataImportHandlerException: Could not load driver: Processing Document # 1
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:406)
at org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:319)
at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:227)
... 3 more
Caused by: org.apache.solr.handler.dataimport.DataImportHandlerException: Could not load driver: Processing Document # 1
at org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow(DataImportHandlerException.java:71)
at org.apache.solr.handler.dataimport.JdbcDataSource.createConnectionFactory(JdbcDataSource.java:114)
at org.apache.solr.handler.dataimport.JdbcDataSource.init(JdbcDataSource.java:62)
at org.apache.solr.handler.dataimport.DataImporter.getDataSourceInstance(DataImporter.java:394)
at org.apache.solr.handler.dataimport.ContextImpl.getDataSource(ContextImpl.java:99)
at org.apache.solr.handler.dataimport.SqlEntityProcessor.init(SqlEntityProcessor.java:53)
at org.apache.solr.handler.dataimport.EntityProcessorWrapper.init(EntityProcessorWrapper.java:74)
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:423)
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:404)
... 5 more
Caused by: java.lang.ClassNotFoundException: Unable to load or org.apache.solr.handler.dataimport.
at org.apache.solr.handler.dataimport.DocBuilder.loadClass(DocBuilder.java:911)
at org.apache.solr.handler.dataimport.JdbcDataSource.createConnectionFactory(JdbcDataSource.java:112)
... 12 more
Caused by: org.apache.solr.common.SolrException: Error loading class ''
at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:440)
at org.apache.solr.handler.dataimport.DocBuilder.loadClass(DocBuilder.java:901)
... 13 more
Caused by: java.lang.ClassNotFoundException:
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:424)
... 14 more
如果我在data-config.xml中硬编码属性,那么导入工作正常。
data-config.xml和solrcore.properties都在dir下
project_name/solr/app-cores/core_name/conf
然后从here获取提示并尝试在solr-config.xml中的数据导入请求处理程序中配置属性,如下所示:
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">data-config.xml</str>
<str name="jdbcDriver">${jdbc.driver}</str>
<str name="jdbcHost">${jdbc.host}</str>
<str name="jdbcPort">${jdbc.port}</str>
<str name="jdbcUsername">${jdbc.username}</str>
<str name="jdbcPassword">${jdbc.password}</str>
</lst>
</requestHandler>
并在像{dataimport.jdbcDriver}
和{dataimport.request.jdbcDriver}
这样的data-config.xml中使用它们,但是它们会抛出相同的异常!
如何解决这个问题?
答案 0 :(得分:2)
将${dataimporter.request.jdbcDriver}
与请求处理程序方法结合使用!