1
votes

I'm trying to make a full import with solr and receiving the following error:

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>  

Could it be that it's not possible to use integrated security?

Or is there anything wrong with the connection string?

UPDATE:

I'm running the jetty that comes with the example when downloading solr.

I have edited the db example to use sql server.

I copied sqljdbc.jar and sqljdbc4.jar to \solr-4.6.0\example\example-DIH\solr\db\lib and \solr-4.6.0\example\lib

The home directory is set to \solr-4.6.0\example\example-DIH\solr

Now it's a new error:

16:29:54 ERROR DocBuilder Exception while processing: member document : SolrInputDocument(fields: []):org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to execute query: SELECT * FROM Members Processing Document # 1

16:29:54 ERROR DataImporter Full Import failed:java.lang.RuntimeException: java.lang.RuntimeException: org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to execute query: SELECT * FROM Members Processing Document # 1

16:29:55 ERROR DocBuilder Exception while processing: member document : SolrInputDocument(fields: []):org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to execute query: SELECT * FROM Members Processing Document # 1

16:29:55 ERROR DataImporter Full Import failed:java.lang.RuntimeException: java.lang.RuntimeException: org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to execute query: SELECT * FROM Members Processing Document # 1

I also get a warning about unique key:

16:29:49 WARN IndexSchema no uniqueKey specified in schema.

Even though I have set id to 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

1 Answers

0
votes

No, as it clearly says in the error log, your JDBC driver jar file is missing for com.microsoft.sqlserver.jdbc.SQLServerDriver.That is provided by vendor , in this case microsfot sqlserver. you need to make that available to container that is running your solr instance. If you are using tomcat copy it into tomcat_home\lib directory. You will find the jar file in your sql server installation or ask your sql server admin.