Solr dataSource错误

时间:2013-12-19 14:07:47

标签: solr indexing

我正在尝试使用solr进行完全导入并收到以下错误:

DataImporter Full Import failed:java.lang.RuntimeException: java.lang.RuntimeException: org.apache.solr.handler.dataimport.DataImportHandlerException: Could not load driver: com.microsoft.sqlserver.jdbc.SQLServerDriver Processing Document # 1  
Full Import failed:java.lang.RuntimeException: java.lang.RuntimeException: org.apache.solr.handler.dataimport.DataImportHandlerException: Could not load driver: com.microsoft.sqlserver.jdbc.SQLServerDriver Processing Document # 1
    at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:270)
    at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:411)
    at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:476)
    at org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:457)
Caused by: java.lang.RuntimeException: org.apache.solr.handler.dataimport.DataImportHandlerException: Could not load driver: com.microsoft.sqlserver.jdbc.SQLServerDriver Processing Document # 1
    at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:410)
    at org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:323)
    at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:231)
    ... 3 more
Caused by: org.apache.solr.handler.dataimport.DataImportHandlerException: Could not load driver: com.microsoft.sqlserver.jdbc.SQLServerDriver Processing Document # 1
    at org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow(DataImportHandlerException.java:71)
    at org.apache.solr.handler.dataimport.JdbcDataSource.createConnectionFactory(JdbcDataSource.java:116)
    at org.apache.solr.handler.dataimport.JdbcDataSource.init(JdbcDataSource.java:64)
    at org.apache.solr.handler.dataimport.DataImporter.getDataSourceInstance(DataImporter.java:383)
    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:427)
    at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:408)
    ... 5 more
Caused by: java.lang.ClassNotFoundException: Unable to load com.microsoft.sqlserver.jdbc.SQLServerDriver or org.apache.solr.handler.dataimport.com.microsoft.sqlserver.jdbc.SQLServerDriver
    at org.apache.solr.handler.dataimport.DocBuilder.loadClass(DocBuilder.java:916)
    at org.apache.solr.handler.dataimport.JdbcDataSource.createConnectionFactory(JdbcDataSource.java:114)
    ... 12 more
Caused by: org.apache.solr.common.SolrException: Error loading class 'com.microsoft.sqlserver.jdbc.SQLServerDriver'
    at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:470)
    at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:401)
    at org.apache.solr.handler.dataimport.DocBuilder.loadClass(DocBuilder.java:906)
    ... 13 more
Caused by: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.net.FactoryURLClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:454)
<dataConfig>  
  <dataSource
    type="JdbcDataSource"
    driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" 
    url="jdbc:sqlserver://localhost\ARBETSDATOR\SQLEXPRESS;integratedSecurity=true;databaseName=189021-resurs"/>  

  <document name="members">  

    <entity name="member" query="SELECT * FROM Members">  

      <field column="MemberId" name="id"/>  
      <field column="Name" name="name"/>  

    </entity>  
  </document>  

</dataConfig>  

可能是因为不可能使用集成安全性吗?

或者连接字符串有什么问题吗?

更新

下载solr时,我正在运行示例附带的码头。

我编写了db示例以使用sql server。

我已将sqljdbc.jarsqljdbc4.jar复制到\solr-4.6.0\example\example-DIH\solr\db\lib\solr-4.6.0\example\lib

主目录设置为\solr-4.6.0\example\example-DIH\solr

现在这是一个新错误:

  

16:29:54错误DocBuilder处理时出现异常:成员文档:SolrInputDocument(fields:[]):org.apache.solr.handler.dataimport.DataImportHandlerException:无法执行查询:SELECT * FROM Members Processing Document#1

     

16:29:54错误DataImporter完全导入失败:java.lang.RuntimeException:java.lang.RuntimeException:org.apache.solr.handler.dataimport.DataImportHandlerException:无法执行查询:SELECT * FROM Members Processing Document# 1

     

16:29:55错误DocBuilder处理时出现异常:成员文档:SolrInputDocument(fields:[]):org.apache.solr.handler.dataimport.DataImportHandlerException:无法执行查询:SELECT * FROM Members Processing Document#1

     

16:29:55错误DataImporter完全导入失败:java.lang.RuntimeException:java.lang.RuntimeException:org.apache.solr.handler.dataimport.DataImportHandlerException:无法执行查询:SELECT * FROM Members Processing Document# 1

我也收到有关唯一密钥的警告:

  

16:29:49 WARN IndexSchema架构中没有指定uniqueKey。

即使我已将id设为uniqueKey

<fields>  
 <field name="id" type="string" indexed="true" stored="true" required="true" />  
 <field name="name" type="text" indexed="true" stored="true"/>  

 <field name="text" type="text" indexed="true" stored="false" multiValued="true"/>  
</fields>  


 <!-- Field to use to determine and enforce document uniqueness. 
  Unless this field is marked with required="false", it will be a required field
  -->
<uniqueKey>id</uniqueKey>

 <!-- field for the QueryParser to use when an explicit fieldname is absent -->
 <defaultSearchField>text</defaultSearchField>


<copyField source="id" dest="text"/>  
<copyField source="name" dest="text"/>  

1 个答案:

答案 0 :(得分:0)

不,正如它在错误日志中明确指出的那样,com.microsoft.sqlserver.jdbc.SQLServerDriver缺少JDBC驱动程序jar文件。这是由供应商提供的,在本例中是microsfot sqlserver。您需要使其可用于运行solr实例的容器。如果您使用tomcat将其复制到tomcat_home \ lib目录中。您将在sql server安装中找到jar文件或询问您的sql server admin。