TorqueBox
  1. TorqueBox
  2. TORQUE-762

oracle_enhanced errors with No suitable driver found for jdbc:oracle:thin

    Details

    • Type: Bug Bug
    • Status: Closed Closed (View Workflow)
    • Priority: Major Major
    • Resolution: Done
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.0.2
    • Component/s: Rails
    • Labels:
      None
    • Environment:
      mac oxs 10.6.8; Java(TM) SE Runtime Environment (build 1.6.0_31-b04-413-10M3623)
    • Workaround:
      Workaround Exists
    • Workaround Description:
      Hide

      See https://gist.github.com/2471698 for a workaround until the issue gets fixed in oracle_enhanced adapter

      Show
      See https://gist.github.com/2471698 for a workaround until the issue gets fixed in oracle_enhanced adapter
    • Similar Issues:
      Show 10 results 

      Description

      I got the following error when doing "torquebox run" locally:

      22:02:28,822 ERROR [org.torquebox.core.runtime] (Thread-99) Error during execution: ENV['RAILS_ROOT']=RACK_ROOT
      ENV['RAILS_ENV']=RACK_ENV
      require %q(org/torquebox/web/rails/boot)
      : org.jruby.exceptions.RaiseException: (NativeException) java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@server-name:1531:MYDEV
      at java.sql.DriverManager.getConnection(DriverManager.java:602) [classes.jar:1.6.0_31]
      at java.sql.DriverManager.getConnection(DriverManager.java:154) [classes.jar:1.6.0_31]

      22:02:28,827 ERROR [org.torquebox.core.runtime] (Thread-99) Failed to initialize runtime: : org.jruby.exceptions.RaiseException: (NativeException) java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@uppdev-db.oit.duke.edu:1627:UPPDEV
      at java.sql.DriverManager.getConnection(DriverManager.java:602) [classes.jar:1.6.0_31]
      at java.sql.DriverManager.getConnection(DriverManager.java:154) [classes.jar:1.6.0_31]

      I created a sample application here:

      https://github.com/outten45/torquebox-oracle-sample

      You will need to download and put the ojdbc6.jar into the lib directory. You will also need to create a database.yml with your settings from the database.yml.sample.

      If I run the application in webbrick (rails server) and trinidad (trinidad -p 8080), it works without a problem.

        Activity

        Hide
        Aurélien DEHAY
        added a comment -

        Hello.

        Even if it's working in Webrick & Trinidad with that conf, did you try to use oracle.jdbc.OracleDriver instead of oracle.jdbc.driver.OracleDriver ?

        Rgds.

        Show
        Aurélien DEHAY
        added a comment - Hello. Even if it's working in Webrick & Trinidad with that conf, did you try to use oracle.jdbc.OracleDriver instead of oracle.jdbc.driver.OracleDriver ? Rgds.
        Hide
        Richard Outten
        added a comment -

        Just to follow up, I did try updating the driver to oracle.jdbc.OracleDriver and that didn't help. I also tried deploying the ojdbc6.jar directly to the deployments directory, since it is JDBC-4 driver and appears to register itself (see https://community.jboss.org/wiki/DataSourceConfigurationInAS7#Installing_a_JDBC_driver_as_a_deployment), but that didn't seem to help.

        Thanks,
        Richard

        Show
        Richard Outten
        added a comment - Just to follow up, I did try updating the driver to oracle.jdbc.OracleDriver and that didn't help. I also tried deploying the ojdbc6.jar directly to the deployments directory, since it is JDBC-4 driver and appears to register itself (see https://community.jboss.org/wiki/DataSourceConfigurationInAS7#Installing_a_JDBC_driver_as_a_deployment ), but that didn't seem to help. Thanks, Richard
        Hide
        Benjamin Browning
        added a comment -

        The root of the issue is that oracle_enhanced uses java.sql.DriverManager to register the Oracle JDBC driver and obtain a connection. However, as activerecord-jdbc found out, this doesn't work with dynamically loaded JDBC drivers. It will only work if the JDBC driver is loaded in the system classloader. For an example of how activerecord-jdbc works around this, see https://github.com/jruby/activerecord-jdbc-adapter/blob/master/lib/arjdbc/jdbc/driver.rb#L26-32

        The code in activerecord-jdbc used to try DriverManager.getConnection then fall back to instantiating the driver directly. This is likely what the oracle_enhanced adapter needs to be changed to do.

        Show
        Benjamin Browning
        added a comment - The root of the issue is that oracle_enhanced uses java.sql.DriverManager to register the Oracle JDBC driver and obtain a connection. However, as activerecord-jdbc found out, this doesn't work with dynamically loaded JDBC drivers. It will only work if the JDBC driver is loaded in the system classloader. For an example of how activerecord-jdbc works around this, see https://github.com/jruby/activerecord-jdbc-adapter/blob/master/lib/arjdbc/jdbc/driver.rb#L26-32 The code in activerecord-jdbc used to try DriverManager.getConnection then fall back to instantiating the driver directly. This is likely what the oracle_enhanced adapter needs to be changed to do.
        Hide
        Benjamin Browning
        added a comment -

        Workaround added

        Show
        Benjamin Browning
        added a comment - Workaround added
        Hide
        Richard Outten
        added a comment -

        Benjamin,

        Thanks for posting this. Your workaround worked for me. When I get a chance, I'll bring it up with the oracle_enhanced maintainer.

        -Richard

        Show
        Richard Outten
        added a comment - Benjamin, Thanks for posting this. Your workaround worked for me. When I get a chance, I'll bring it up with the oracle_enhanced maintainer. -Richard
        Hide
        Benjamin Browning
        added a comment -
        Show
        Benjamin Browning
        added a comment - Pull request sent upstream - https://github.com/rsim/oracle-enhanced/pull/164 Upstream issue - https://github.com/rsim/oracle-enhanced/issues/163
        Hide
        Benjamin Browning
        added a comment -

        Resolving the issue since my pull request has been merged into oracle_enhanced master. The next release of the oracle_enhanced driver should just work on TorqueBox.

        Show
        Benjamin Browning
        added a comment - Resolving the issue since my pull request has been merged into oracle_enhanced master. The next release of the oracle_enhanced driver should just work on TorqueBox.
        Hide
        Brian Ploetz
        added a comment -

        Does the workaround noted only work in 2.0.x versions of Torquebox? I'm still getting this error with Torquebox 2.1.2, and I've tried adding the workaround initializer with the ojdbc6.jar file in the lib/ directory of my Rails app, to no avail. I've also tried using 1.4.2.rc1 of the activerecord-oracle_enhanced-adapter gem, which appears to have the pull request mentioned above to fix this issue, but that doesn't work either.

        Show
        Brian Ploetz
        added a comment - Does the workaround noted only work in 2.0.x versions of Torquebox? I'm still getting this error with Torquebox 2.1.2, and I've tried adding the workaround initializer with the ojdbc6.jar file in the lib/ directory of my Rails app, to no avail. I've also tried using 1.4.2.rc1 of the activerecord-oracle_enhanced-adapter gem, which appears to have the pull request mentioned above to fix this issue, but that doesn't work either.
        Hide
        Benjamin Browning
        added a comment -

        Are you using JRuby 1.7.0 or higher by any chance? I think the way it changes exception handling might break things and will need a different workaround and/or pull request sent to oracle enhanced.

        Show
        Benjamin Browning
        added a comment - Are you using JRuby 1.7.0 or higher by any chance? I think the way it changes exception handling might break things and will need a different workaround and/or pull request sent to oracle enhanced.
        Hide
        Brian Ploetz
        added a comment -

        Yes, using JRuby 1.7.0

        Show
        Brian Ploetz
        added a comment - Yes, using JRuby 1.7.0

          People

          • Assignee:
            Benjamin Browning
            Reporter:
            Richard Outten
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: