5 Replies Latest reply on Jan 11, 2012 1:18 AM by samuthra

    Cannot create JDBC driver error: BasicDataSource with Oracle

    dlo1957

      I am getting an error when trying to use a "org.apache.commons.dbcp.BasicDataSource" with Oracle:

       

      Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'oracle.jdbc.OracleDriver' for connect URL 'jdbc:oracle:thin:@127.0.0.1:1521:XE'

           at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1163)[194:org.apache.servicemix.bundles.commons-dbcp:1.2.2.6]

      ...

      Caused by: java.sql.SQLException: No suitable driver

           at java.sql.DriverManager.getDriver(DriverManager.java:264)[:1.6.0_23]

            

      I realize that many people have the following issue. I have looked at:

       

      http://fusesource.com/forums/thread.jspa?messageID=7745

      http://fusesource.com/forums/thread.jspa?messageID=8620

       

      as well as other issues related to this type of error.

       

      I am using version 4.3.0-fuse-03-00.

       

      1) What I did was to create a bundle fragment called "dbcp-oracle-fragment" as suggested in one of the above posts.

       

      From what I can see in "dbcp-oracle-fragment" after it is installed:

       

      - Imported Packages     oracle.jdbc from com.springsource.oracle.jdbc (195)

      - Fragment-Host: org.apache.servicemix.bundles.commons-dbcp; bundle-version=1.2.2

       

      Here's more detailed information.

       

      a) In "dbcp-oracle-fragment"

       

      Integration Services :: DBCP Fragment :: Oracle Driver (dbcp-oracle-fragment)

      Symbolic Name     dbcp-oracle-fragment

      Version     1.0.02.SNAPSHOT

      Bundle Location     mvn:ca.ne2.integration/dbcp-oracle-fragment/1.0.02-SNAPSHOT

      Last Modification     Thu Mar 17 15:41:27 MDT 2011

      Bundle Documentation     http://fusesource.com/

      Vendor     FuseSource

      Description     This pom provides project information that is common to all ServiceMix branches.

      Start Level     60

      Imported Packages     oracle.jdbc from com.springsource.oracle.jdbc (195)

      Manifest Headers     Manifest-Version: 1.0

      Built-By: dlo

      Tool: Bnd-0.0.357

      Bundle-Name: Integration Services :: DBCP Fragment :: Oracle Driver

      Created-By: Apache Maven Bundle Plugin

      Bundle-Vendor: FuseSource

      Fragment-Host: org.apache.servicemix.bundles.commons-dbcp; bundle-version=1.2.2

      Build-Jdk: 1.6.0_23

      Bundle-Version: 1.0.02.SNAPSHOT

      Bnd-LastModified: 1300396354422

      Bundle-ManifestVersion: 2

      Bundle-Description: This pom provides project information that is common to all ServiceMix branches.

      Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt

      Bundle-SymbolicName: dbcp-oracle-fragment

      Bundle-DocURL: http://fusesource.com/

      Import-Package: oracle.jdbc

       

      b) Here's what bundle "org.apache.servicemix.bundles.commons-dbcp" looks like:

       

      Apache ServiceMix :: Bundles :: commons-dbcp (org.apache.servicemix.bundles.commons-dbcp)

      Symbolic Name     org.apache.servicemix.bundles.commons-dbcp

      Version     1.2.2.6

      Bundle Location     mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-dbcp

      Last Modification     Thu Mar 17 15:16:06 MDT 2011

      Bundle Documentation     http://www.apache.org/

      Vendor     The Apache Software Foundation

      Description     This bundle simply wraps commons-dbcp-1.2.2.jar.

      Start Level     60

      Exported Packages     org.apache.commons.dbcp,version=1.2.2

      org.apache.commons.dbcp,version=1.2.2

      org.apache.commons.dbcp.cpdsadapter,version=1.2.2

      org.apache.commons.dbcp.cpdsadapter,version=1.2.2

      org.apache.commons.dbcp.datasources,version=1.2.2

      org.apache.commons.dbcp.datasources,version=1.2.2

      org.apache.commons.jocl,version=1.2.2

      org.apache.commons.jocl,version=1.2.2

      Imported Packages     javax.naming,version=0.0.0 from org.eclipse.osgi (0)

      javax.naming.spi,version=0.0.0 from org.eclipse.osgi (0)

      javax.sql,version=0.0.0 from org.eclipse.osgi (0)

      org.apache.commons.pool,version=1.5.4 from org.apache.servicemix.bundles.commons-pool (37)

      org.apache.commons.pool.impl,version=1.5.4 from org.apache.servicemix.bundles.commons-pool (37)

      org.xml.sax,version=0.0.0 from org.eclipse.osgi (0)

      org.xml.sax.helpers,version=0.0.0 from org.eclipse.osgi (0)

      Importing Bundles     ca.ne2.integration.in.ne.exchange.ne-exchange-event-consumer (202)

      neis-common-oracle-pool (197)

      Manifest Headers     Manifest-Version: 1.0

      Built-By: jb

      Created-By: Apache Maven Bundle Plugin

      Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt

      Import-Package: javax.naming, javax.naming.spi, javax.sql, org.apache.commons.pool; version="[1.3, 2)", org.apache.commons.pool.impl; version="[1.3, 2)", org.xml.sax, org.xml.sax.helpers

      Bnd-LastModified: 1282729401614

      Export-Package: org.apache.commons.dbcp.cpdsadapter; uses:="javax.naming, org.apache.commons.pool.impl, org.apache.commons.pool, javax.naming.spi, javax.sql, org.apache.commons.dbcp"; version="1.2.2", org.apache.commons.dbcp.datasources; uses:="org.apache.commons.pool, org.apache.commons.dbcp, javax.sql, javax.naming, javax.naming.spi, org.apache.commons.pool.impl"; version="1.2.2", org.apache.commons.dbcp; uses:="org.apache.commons.pool.impl, org.apache.commons.pool, javax.sql, javax.naming, javax.naming.spi, org.xml.sax, org.apache.commons.jocl"; version="1.2.2", org.apache.commons.jocl; uses:="org.xml.sax, org.xml.sax.helpers"; version="1.2.2"

      Bundle-Version: 1.2.2.6

      Bundle-Name: Apache ServiceMix :: Bundles :: commons-dbcp

      Bundle-Description: This bundle simply wraps commons-dbcp-1.2.2.jar.

      Build-Jdk: 1.5.0_14

      Bundle-DocURL: http://www.apache.org/

      Bundle-Vendor: The Apache Software Foundation

      Bundle-ManifestVersion: 2

      Bundle-SymbolicName: org.apache.servicemix.bundles.commons-dbcp

      Tool: Bnd-0.0.357

       

      c) My data source is defined as:

       

            

       

      I've spent hours on this and I am at a loss as what to do next.

       

      Does anyone have any ideas on what the problem is?

            

      Thanks.

        • 1. Re: Cannot create JDBC driver error: BasicDataSource with Oracle
          ffang

          Hi,

           

          Could you use osgi:list

          and post the output about

          your fragment bundle and commons-dbcp bundle?

          I'd like to see if commons-dbcp correctly pick up your fragment.

          You need refresh hosts bundle after you install fragment bundle.

           

          In our FUSE ESB kit, there're fragment-host bundles pair get installed out-of-box, they're  activemq-core and activemq-blueprint, the status is like

          activemq-core (5.4.2.fuse-01-00)

                                                 Fragments: 53

          activemq-blueprint (5.4.2.fuse-01-00)

                                                 Hosts: 43

           

           

          Your fragment-host bundles pair should be similar when you use osgi:list

          Btw, ensure fragment bundle already contain the JDBC driver classes.

           

          Freeman

          • 2. Re: Cannot create JDBC driver error: BasicDataSource with Oracle
            dlo1957

            After reading your response I was able to resolve the issue.

             

            The osgi:list produced:

             

            [] [] Oracle JDBC Driver (10.2.0.2)

             

            [] [] Apache ServiceMix :: Bundles :: commons-dbcp (1.2.2.6)

            Fragments: 204

             

            [] [] Integration Services :: DBCP Fragment :: Oracle Driver (1.0.02.SNAPSHOT)

            Hosts: 203

             

            The problem was that I was not importing all of the packages from "Oracle JDBC Driver (10.2.0.2)" into my fragment "Integration Services :: DBCP Fragment...".

             

            Once I added all of the "Exported Packages" to the fragment it worked.

             

            Thanks for you help.

            • 3. Re: Cannot create JDBC driver error: BasicDataSource with Oracle
              samuthra

              Hi,

               

              I am a beginner in Fuse ESB. I face the same driver not found issue. Can you please tell me how to create the fragment bundle for oracle jdbc driver. Please guide me.

               

              Many Thanks in advance...

               

              Regards,

              Ramesh

              • 4. Re: Cannot create JDBC driver error: BasicDataSource with Oracle
                ffang

                Hi,

                 

                You need tell us what's the problem you encounter.

                I suggest you use maven-bundle-plugin to do it, although you can also use java bnd tool directly from command line, but the maven-bundle-plugin with pom.xml should be easy for configuration.

                Basically you just need write a pom.xml which use maven-bundle-plugin and have jdbc driver dependency in it, and in the maven-bundle-plugin configuration you need  specify

                <Fragment-Host>Bundle-SymbolicName of the host bundle</Fragment-Host>.

                 

                You may need google to get more concept about the OSGi host/fragment bundles.

                 

                Freeman

                • 5. Re: Cannot create JDBC driver error: BasicDataSource with Oracle
                  samuthra

                  Thanks for the immediate response. I love this community....