Solr
  1. Solr
  2. SOLR-726

driver and datasources are not loaded using the multicore lib aware SolrResourceLoader

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.3
    • Fix Version/s: 1.3
    • Labels:
      None

      Description

      see http://www.nabble.com/dataimporthandler-and-mysql-connector-jar-td19146229.html
      The jar containing the (jdbc) driver have to be present in the java classpath. Putting it in coreX/lib or in the shared lib dir of a multicore solr doesn't work

      1. SOLR-726.patch
        13 kB
        Shalin Shekhar Mangar
      2. SOLR-726.patch
        11 kB
        Noble Paul

        Activity

        Walter Ferrara created issue -
        Hide
        Shalin Shekhar Mangar added a comment -

        Marking this bug for 1.3

        Show
        Shalin Shekhar Mangar added a comment - Marking this bug for 1.3
        Shalin Shekhar Mangar made changes -
        Field Original Value New Value
        Assignee Shalin Shekhar Mangar [ shalinmangar ]
        Fix Version/s 1.3 [ 12312486 ]
        Hide
        Noble Paul added a comment -

        classloading is done using SolrCore#getResourceLoader()#findClass(name)

        Show
        Noble Paul added a comment - classloading is done using SolrCore#getResourceLoader()#findClass(name)
        Noble Paul made changes -
        Attachment SOLR-726.patch [ 12389065 ]
        Hide
        Shalin Shekhar Mangar added a comment -

        Using SolrResourceLoader#findClass does not solve the problem. From the official documentation at http://java.sun.com/j2se/1.5.0/docs/guide/jdbc/getstart/drivermanager.html

        For security reasons, the JDBC management layer will keep track of which class loader provided which driver. Then when the DriverManager class is opening a connection, it will use only drivers that come from the local file system or from the same class loader as the code issuing the request for a connection.

        Since the loading is done by SolrResourceLoader using a different class loader and the call to DriverManager.getConnection is made from a different one, a SQLException is thrown – "java.sql.SQLException: No suitable driver".

        Show
        Shalin Shekhar Mangar added a comment - Using SolrResourceLoader#findClass does not solve the problem. From the official documentation at http://java.sun.com/j2se/1.5.0/docs/guide/jdbc/getstart/drivermanager.html For security reasons, the JDBC management layer will keep track of which class loader provided which driver. Then when the DriverManager class is opening a connection, it will use only drivers that come from the local file system or from the same class loader as the code issuing the request for a connection. Since the loading is done by SolrResourceLoader using a different class loader and the call to DriverManager.getConnection is made from a different one, a SQLException is thrown – "java.sql.SQLException: No suitable driver".
        Hide
        Shalin Shekhar Mangar added a comment -

        A hackish work around to the class loader issue.

        This patch tries to use SolrResourceLoader#findClass to load the Driver class. It tries to use DriverManager#getConnection. If that fails, we try to instantiate the Driver class and use the Driver#connect method directly bypassing the DriverManager. This workaround is documented in the JdbcDataSource class.

        I will commit this shortly.

        Show
        Shalin Shekhar Mangar added a comment - A hackish work around to the class loader issue. This patch tries to use SolrResourceLoader#findClass to load the Driver class. It tries to use DriverManager#getConnection. If that fails, we try to instantiate the Driver class and use the Driver#connect method directly bypassing the DriverManager. This workaround is documented in the JdbcDataSource class. I will commit this shortly.
        Shalin Shekhar Mangar made changes -
        Attachment SOLR-726.patch [ 12389143 ]
        Hide
        Shalin Shekhar Mangar added a comment -

        Committed revision 690131.

        Thanks Walter and Noble!

        Show
        Shalin Shekhar Mangar added a comment - Committed revision 690131. Thanks Walter and Noble!
        Shalin Shekhar Mangar made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Uwe Schindler made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development