2012-01-25 135 views
1

我試圖搜索我的具體問題,但還沒有找到解決方案。我也讀過DIH上的維基,並且似乎已經設置正確,但是我的查詢仍然失敗。感謝您的幫助DataImportHandlerException:無法執行查詢

我正在運行的Solr 3.1和Tomcat 6.0 的Windows Server 2003 R2和SQL 2008

我有sqljdbc4.jar坐在C:\ Program Files文件\ Apache軟件基金會\ Tomcat的6.0 \ LIB

我solrconfig.xml中

<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler"> 
<lst name="defaults"> 
    <str name="config">db-data-config.xml</str> 
    </lst> 
    </requestHandler> 

我的數據庫數據-config.xml中

<dataConfig> 
<dataSource driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"  url="://localhost:1433;DatabaseName=KnowledgeBase_DM" user="user" password="password" /> 
<document> 
<entity name="Titles" query="SELECT mrID, mrTitle from KnowledgeBase_DM.dbo.AskMe_Data"> 
<field column="mrID" name="id" /> 
<field column="mrTitle" name="title" /> 
<entity name="Desc" query="select meDescription from KnowledgeBase_DM.dbo.AskMe_Data"> 
<field column="meDescription" name="description" /> 
</entity> 
</entity> 
</document> 
</dataConfig> 

內容的日誌:

Jan 25, 2012 2:17:37 PM org.apache.solr.handler.dataimport.DataImportHandler processConfiguration 
INFO: Processing configuration from solrconfig.xml: {config=db-data-config.xml} 
Jan 25, 2012 2:17:37 PM org.apache.solr.handler.dataimport.DataImporter loadDataConfig 
INFO: Data Configuration loaded successfully 
Jan 25, 2012 2:17:37 PM org.apache.solr.handler.dataimport.DataImporter doFullImport 
INFO: Starting Full Import 
Jan 25, 2012 2:17:37 PM org.apache.solr.handler.dataimport.SolrWriter readIndexerProperties 
**WARNING: Unable to read: dataimport.properties** 
Jan 25, 2012 2:17:37 PM org.apache.solr.handler.dataimport.JdbcDataSource$1 call 
INFO: Creating a connection for entity Titles with URL: ://localhost:1433;DatabaseName=KnowledgeBase_DM 
Jan 25, 2012 2:17:37 PM org.apache.solr.handler.dataimport.JdbcDataSource$1 call 
INFO: Time taken for getConnection(): 0 
Jan 25, 2012 2:17:37 PM org.apache.solr.common.SolrException log 
**SEVERE: Exception while processing: Titles document : SolrInputDocument[{}]:org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to execute query: SELECT mrID, mrTitle from KnowledgeBase_DM.dbo.AskMe_Data Processing Document # 1** 
     at org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow(DataImportHandlerException.java:72) 
     at org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.<init>(JdbcDataSource.java:253) 
     at org.apache.solr.handler.dataimport.JdbcDataSource.getData(JdbcDataSource.java:210) 
     at org.apache.solr.handler.dataimport.JdbcDataSource.getData(JdbcDataSource.java:39) 
     at org.apache.solr.handler.dataimport.DebugLogger$2.getData(DebugLogger.java:188) 
     at org.apache.solr.handler.dataimport.SqlEntityProcessor.initQuery(SqlEntityProcessor.java:59) 
     at org.apache.solr.handler.dataimport.SqlEntityProcessor.nextRow(SqlEntityProcessor.java:73) 
     at org.apache.solr.handler.dataimport.EntityProcessorWrapper.nextRow(EntityProcessorWrapper.java:238) 
     at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:591) 
     at org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:267) 
     at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:186) 
     at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:353) 
     at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:411) 
     at org.apache.solr.handler.dataimport.DataImportHandler.handleRequestBody(DataImportHandler.java:205) 
     at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:129) 
     at org.apache.solr.core.SolrCore.execute(SolrCore.java:1360) 
     at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:356) 
     at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:252) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) 
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) 
     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) 
     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602) 
     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) 
     at java.lang.Thread.run(Unknown Source) 
Caused by: java.lang.NullPointerException 
     at org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.<init>(JdbcDataSource.java:241) 
     ... 28 more 

Jan 25, 2012 2:17:37 PM org.apache.solr.common.SolrException log 
**SEVERE: Full Import failed:org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to execute query: SELECT mrID, mrTitle from KnowledgeBase_DM.dbo.AskMe_Data Processing Document # 1** 
     at org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow(DataImportHandlerException.java:72) 
     at org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.<init>(JdbcDataSource.java:253) 
     at org.apache.solr.handler.dataimport.JdbcDataSource.getData(JdbcDataSource.java:210) 
     at org.apache.solr.handler.dataimport.JdbcDataSource.getData(JdbcDataSource.java:39) 
     at org.apache.solr.handler.dataimport.DebugLogger$2.getData(DebugLogger.java:188) 
     at org.apache.solr.handler.dataimport.SqlEntityProcessor.initQuery(SqlEntityProcessor.java:59) 
     at org.apache.solr.handler.dataimport.SqlEntityProcessor.nextRow(SqlEntityProcessor.java:73) 
     at org.apache.solr.handler.dataimport.EntityProcessorWrapper.nextRow(EntityProcessorWrapper.java:238) 
     at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:591) 
     at org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:267) 
     at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:186) 
     at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:353) 
     at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:411) 
     at org.apache.solr.handler.dataimport.DataImportHandler.handleRequestBody(DataImportHandler.java:205) 
     at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:129) 
     at org.apache.solr.core.SolrCore.execute(SolrCore.java:1360) 
     at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:356) 
     at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:252) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) 
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) 
     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) 
     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602) 
     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) 
     at java.lang.Thread.run(Unknown Source) 
Caused by: java.lang.NullPointerException 
     at org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.<init>(JdbcDataSource.java:241) 
     ... 28 more 

Jan 25, 2012 2:17:37 PM org.apache.solr.update.DirectUpdateHandler2 rollback 
INFO: start rollback 
Jan 25, 2012 2:17:37 PM org.apache.solr.update.DirectUpdateHandler2 rollback 
INFO: end_rollback 
Jan 25, 2012 2:17:37 PM org.apache.solr.core.SolrCore execute 
INFO: [] webapp=/solr path=/select params={start=0&dataConfig=<dataConfig>%0d%0a%09<dataSource+driver%3D"com.microsoft.sqlserver.jdbc.SQLServerDriver"+url%3D"://localhost:1433;DatabaseName%3DKnowledgeBase_DM"+user%3D"user"+password%3D"password"+/>%0d%0a%09<document>%0d%0a%09%09<entity+dataSource%3D"ds1"+name%3D"Titles"+query%3D"SELECT+mrID,+mrTitle+from+KnowledgeBase_DM.dbo.AskMe_Data">%0d%0a%09%09%09<field+column%3D"mrID"+name%3D"id"+/>%0d%0a%09%09%09<field+column%3D"mrTitle"+name%3D"title"+/>%0d%0a%09%09%09<entity+name%3D"Desc"+query%3D"select+meDescription+from+KnowledgeBase_DM.dbo.AskMe_Data">%0d%0a%09%09%09%09<field+column%3D"meDescription"+name%3D"description"+/>%0d%0a%09%09%09</entity>%0d%0a%09%09</entity>%0d%0a%09</document>%0d%0a</dataConfig>&verbose=on&command=full-import&debug=on&qt=/dataimport&rows=10} status=0 QTime=10 

回答

1

看起來你忘了描述您要用來連接數據庫的協議。 對於MSSQL是

url="jdbc:sqlserver://localhost:1433;DatabaseName=KnowledgeBase_DM" 

我敢肯定,你不需要重申週二數據庫名稱在您查詢既然你選擇它的話,你的網址。至極使得查詢:

query="SELECT mrID, mrTitle from dbo.AskMe_Data" 

我從來沒有工作過的機智MSSQL,所以我不知道你是否應該使用dbo.AskMe_Data或只是,就像我一直用它,AskMe_Data

我認爲此代碼應解決該問題:

<dataConfig> 
    <dataSource type="JdbcDataSource" driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" 
     url="jdbc:sqlserver://localhost:1433;DatabaseName=KnowledgeBase_DM" user="user" password="password" /> 
    <document> 
     <entity name="Titles" query="SELECT mrID, mrTitle from dbo.AskMe_Data"> 
      <field column="mrID" name="id" /> 
      <field column="mrTitle" name="title" /> 
      <entity name="Desc" query="select meDescription from dbo.AskMe_Data"> 
       <field column="meDescription" name="description" /> 
      </entity> 
     </entity> 
    </document> 
</dataConfig> 
+0

daanTracebuzz, 我做了這些改變,但我仍然得到同樣的錯誤,我認爲它還是有更多的事情要做**警告:無法讀取:dataimport.properties **我不認爲它甚至到達實際的sql執行部分。有關於此的服務教程,我已經跟隨了一些,但通常會得到相同的結果。 – user1170248

+0

那麼堆棧跟蹤中的'WARNING'從來就不是完全錯誤的地方,它試圖執行查詢的地方出錯了。在那裏它寫着'SERVERE',那是真正的錯誤。 – Daan

+0

我發現我們仍然錯過了dataSource中的類型聲明,不適合添加它 – Daan

-1

的sqljdbc4.jar應放置在另一個目錄

如果這是你的配置文件

的地方
C:\Program Files\Apache Software Foundation\Tomcat 6.0\solr\conf\solrconfig.xml 

然後sqljdbc4.jar應該放在這裏:

C:\Program Files\Apache Software Foundation\Tomcat 6.0\solr\lib\sqljdbc4.jar 
+0

它也可以幫助重新開始一個完全空的solr並重建整個事情。 Solr可能有點喜怒無常 – Daan

相關問題