Solr
  1. Solr
  2. SOLR-1269

stack trace not clear when there is a SQL error

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.4
    • Fix Version/s: 1.4
    • Labels:
      None

      Description

      When setting up a new JDBC datasource and the SQL isn't right yet, we are getting a stack trace that says ClassNotFoundException, but that is misleading.

      A cleaner stack trace is warranted, indicating the actual error.

      [actual SQL statement omitted]

      org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to execute query: SELECT ..... Processing Document # 1
      at org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.<init>(JdbcDataSource.java:250)
      at org.apache.solr.handler.dataimport.JdbcDataSource.getData(JdbcDataSource.java:207)
      at org.apache.solr.handler.dataimport.JdbcDataSource.getData(JdbcDataSource.java:40)
      at org.apache.solr.handler.dataimport.SqlEntityProcessor.initQuery(SqlEntityProcessor.java:58)
      at org.apache.solr.handler.dataimport.SqlEntityProcessor.nextRow(SqlEntityProcessor.java:71)
      at org.apache.solr.handler.dataimport.EntityProcessorWrapper.nextRow(EntityProcessorWrapper.java:237)
      at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:343)
      at org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:224)
      at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:167)
      at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:333)
      at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:393)
      at org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:372)
      Caused by: java.lang.ClassNotFoundException: Unable to load null or org.apache.solr.handler.dataimport.null
      at org.apache.solr.handler.dataimport.DocBuilder.loadClass(DocBuilder.java:723)
      at org.apache.solr.handler.dataimport.JdbcDataSource$1.call(JdbcDataSource.java:188)
      at org.apache.solr.handler.dataimport.JdbcDataSource$1.call(JdbcDataSource.java:127)
      at org.apache.solr.handler.dataimport.JdbcDataSource.getConnection(JdbcDataSource.java:362)
      at org.apache.solr.handler.dataimport.JdbcDataSource.access$300(JdbcDataSource.java:40)
      at org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.<init>(JdbcDataSource.java:237)
      ... 11 more
      Caused by: java.lang.NullPointerException
      at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:768)
      at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:280)
      at org.apache.solr.handler.dataimport.DocBuilder.loadClass(DocBuilder.java:713)

      1. SOLR-1269.patch
        6 kB
        Shalin Shekhar Mangar

        Activity

        Hide
        Shalin Shekhar Mangar added a comment -
        1. Used DataImportHandlerException.wrapAndThrow to avoid incorrect messages
        2. Add null check in JdbcDataSource#close
        3. Fixed close() logic so that JdbcDataSource#close is not called after connection timeouts.

        I tried two scenarios:

        1. Incorrect driver name
        2. Incorrect sql query

        With incorrect driver name, before this patch:

        SEVERE: Full Import failed
        org.apache.solr.handler.dataimport.DataImportHandlerException: Failed to initialize DataSource: null Processing Document # 1
        at org.apache.solr.handler.dataimport.DataImporter.getDataSourceInstance(DataImporter.java:307)
        at org.apache.solr.handler.dataimport.ContextImpl.getDataSource(ContextImpl.java:93)
        at org.apache.solr.handler.dataimport.SqlEntityProcessor.init(SqlEntityProcessor.java:52)
        at org.apache.solr.handler.dataimport.EntityProcessorWrapper.init(EntityProcessorWrapper.java:71)
        at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:302)
        at org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:225)
        at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:167)
        at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:333)
        at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:393)
        at org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:372)
        Caused by: org.apache.solr.handler.dataimport.DataImportHandlerException: Could not load driver: org.hsqldb.ajdbcDriver Processing Document # 1
        at org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow(DataImportHandlerException.java:72)
        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:305)
        ... 9 more

        After the patch:

        SEVERE: Full Import failed
        org.apache.solr.handler.dataimport.DataImportHandlerException: Could not load driver: org.hsqldb.ajdbcDriver Processing Document # 1
        at org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow(DataImportHandlerException.java:72)
        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:306)
        at org.apache.solr.handler.dataimport.ContextImpl.getDataSource(ContextImpl.java:93)
        at org.apache.solr.handler.dataimport.SqlEntityProcessor.init(SqlEntityProcessor.java:52)
        at org.apache.solr.handler.dataimport.EntityProcessorWrapper.init(EntityProcessorWrapper.java:71)
        at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:302)
        at org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:225)
        at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:167)
        at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:333)
        at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:393)
        at org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:372)
        Caused by: java.lang.ClassNotFoundException: Unable to load org.hsqldb.ajdbcDriver or org.apache.solr.handler.dataimport.org.hsqldb.ajdbcDriver
        at org.apache.solr.handler.dataimport.DocBuilder.loadClass(DocBuilder.java:717)
        at org.apache.solr.handler.dataimport.JdbcDataSource.createConnectionFactory(JdbcDataSource.java:112)
        ... 11 more

        In the case of incorrect SQL query, the following is logged (before and after is same):

        SEVERE: Exception while processing: item document : SolrInputDocument[{}]
        org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to execute query: select * from item1 Processing Document # 1
        at org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.<init>(JdbcDataSource.java:251)
        at org.apache.solr.handler.dataimport.JdbcDataSource.getData(JdbcDataSource.java:208)
        at org.apache.solr.handler.dataimport.JdbcDataSource.getData(JdbcDataSource.java:39)
        at org.apache.solr.handler.dataimport.SqlEntityProcessor.initQuery(SqlEntityProcessor.java:58)
        at org.apache.solr.handler.dataimport.SqlEntityProcessor.nextRow(SqlEntityProcessor.java:71)
        at org.apache.solr.handler.dataimport.EntityProcessorWrapper.nextRow(EntityProcessorWrapper.java:237)
        at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:339)
        at org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:225)
        at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:167)
        at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:333)
        at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:393)
        at org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:372)
        Caused by: java.sql.SQLException: Table not found in statement [select * from item1]
        at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
        at org.hsqldb.jdbc.jdbcStatement.fetchResult(Unknown Source)
        at org.hsqldb.jdbc.jdbcStatement.execute(Unknown Source)
        at org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.<init>(JdbcDataSource.java:244)
        ... 11 more

        Show
        Shalin Shekhar Mangar added a comment - Used DataImportHandlerException.wrapAndThrow to avoid incorrect messages Add null check in JdbcDataSource#close Fixed close() logic so that JdbcDataSource#close is not called after connection timeouts. I tried two scenarios: Incorrect driver name Incorrect sql query With incorrect driver name, before this patch: SEVERE: Full Import failed org.apache.solr.handler.dataimport.DataImportHandlerException: Failed to initialize DataSource: null Processing Document # 1 at org.apache.solr.handler.dataimport.DataImporter.getDataSourceInstance(DataImporter.java:307) at org.apache.solr.handler.dataimport.ContextImpl.getDataSource(ContextImpl.java:93) at org.apache.solr.handler.dataimport.SqlEntityProcessor.init(SqlEntityProcessor.java:52) at org.apache.solr.handler.dataimport.EntityProcessorWrapper.init(EntityProcessorWrapper.java:71) at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:302) at org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:225) at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:167) at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:333) at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:393) at org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:372) Caused by: org.apache.solr.handler.dataimport.DataImportHandlerException: Could not load driver: org.hsqldb.ajdbcDriver Processing Document # 1 at org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow(DataImportHandlerException.java:72) 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:305) ... 9 more After the patch: SEVERE: Full Import failed org.apache.solr.handler.dataimport.DataImportHandlerException: Could not load driver: org.hsqldb.ajdbcDriver Processing Document # 1 at org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow(DataImportHandlerException.java:72) 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:306) at org.apache.solr.handler.dataimport.ContextImpl.getDataSource(ContextImpl.java:93) at org.apache.solr.handler.dataimport.SqlEntityProcessor.init(SqlEntityProcessor.java:52) at org.apache.solr.handler.dataimport.EntityProcessorWrapper.init(EntityProcessorWrapper.java:71) at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:302) at org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:225) at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:167) at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:333) at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:393) at org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:372) Caused by: java.lang.ClassNotFoundException: Unable to load org.hsqldb.ajdbcDriver or org.apache.solr.handler.dataimport.org.hsqldb.ajdbcDriver at org.apache.solr.handler.dataimport.DocBuilder.loadClass(DocBuilder.java:717) at org.apache.solr.handler.dataimport.JdbcDataSource.createConnectionFactory(JdbcDataSource.java:112) ... 11 more In the case of incorrect SQL query, the following is logged (before and after is same): SEVERE: Exception while processing: item document : SolrInputDocument [{}] org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to execute query: select * from item1 Processing Document # 1 at org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.<init>(JdbcDataSource.java:251) at org.apache.solr.handler.dataimport.JdbcDataSource.getData(JdbcDataSource.java:208) at org.apache.solr.handler.dataimport.JdbcDataSource.getData(JdbcDataSource.java:39) at org.apache.solr.handler.dataimport.SqlEntityProcessor.initQuery(SqlEntityProcessor.java:58) at org.apache.solr.handler.dataimport.SqlEntityProcessor.nextRow(SqlEntityProcessor.java:71) at org.apache.solr.handler.dataimport.EntityProcessorWrapper.nextRow(EntityProcessorWrapper.java:237) at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:339) at org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:225) at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:167) at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:333) at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:393) at org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:372) Caused by: java.sql.SQLException: Table not found in statement [select * from item1] at org.hsqldb.jdbc.Util.sqlException(Unknown Source) at org.hsqldb.jdbc.jdbcStatement.fetchResult(Unknown Source) at org.hsqldb.jdbc.jdbcStatement.execute(Unknown Source) at org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.<init>(JdbcDataSource.java:244) ... 11 more
        Hide
        Shalin Shekhar Mangar added a comment - - edited

        Committed revision 812123.

        Thanks Erik!

        Show
        Shalin Shekhar Mangar added a comment - - edited Committed revision 812123. Thanks Erik!
        Hide
        Grant Ingersoll added a comment -

        Bulk close Solr 1.4 issues

        Show
        Grant Ingersoll added a comment - Bulk close Solr 1.4 issues

          People

          • Assignee:
            Shalin Shekhar Mangar
            Reporter:
            Erik Hatcher
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development