Commons Dbcp
  1. Commons Dbcp
  2. DBCP-363

dbcp bundle should use DynamicImport

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.3, 1.4
    • Fix Version/s: 1.4.1
    • Labels:
      None

      Description

      The bundle provided in the maven central of the commons.dbcp doesn't have a DynamicImport defined. This resolves in following error:
      If you want to use a BasicDataSource class as dataSource and the class is provided by the osgi environment (equinox, ...) the dataSource is not able to be created due to a ClassNotFoundException. If the bundle would have set DynamicImport it works. (I had to change from your bundle to the commons.dbcp bundle provided by servicemix, because there the DynamicImport is set)

        Issue Links

          Activity

          Mark Thomas made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Won't Fix [ 2 ]
          Hide
          Mark Thomas added a comment -

          See DBCP-389 for the enhancement request to provide a DataSourceFactory

          Show
          Mark Thomas added a comment - See DBCP-389 for the enhancement request to provide a DataSourceFactory
          Mark Thomas made changes -
          Link This issue is duplicated by DBCP-386 [ DBCP-386 ]
          Hide
          Balazs Zsoldos added a comment -

          Jukka Zitting: It takes about 10 min to write a DataSourceFactory for any JDBC driver. DynamicImport is one of the biggest mistake inside OSGi a developer can use.

          Instead, please make it possible to create a BasicDataSource based on another DataSource like at https://github.com/everit-org/commons-dbcp-component/blob/master/src/main/java/org/everit/osgi/jdbc/commons/dbcp/BasicSimpleDataSource.java

          Show
          Balazs Zsoldos added a comment - Jukka Zitting : It takes about 10 min to write a DataSourceFactory for any JDBC driver. DynamicImport is one of the biggest mistake inside OSGi a developer can use. Instead, please make it possible to create a BasicDataSource based on another DataSource like at https://github.com/everit-org/commons-dbcp-component/blob/master/src/main/java/org/everit/osgi/jdbc/commons/dbcp/BasicSimpleDataSource.java
          Hide
          Jukka Zitting added a comment -

          Having DynamicImport in place does not prevent DBCP from also using the DataSourceFactory mechanism in OSGi.

          Meanwhile defining DynamicImport for DBCP does solve the problem for cases where the JDBC driver exports the relevant driver classes but does not (yet) implement a DataSourceFactory service.

          Show
          Jukka Zitting added a comment - Having DynamicImport in place does not prevent DBCP from also using the DataSourceFactory mechanism in OSGi. Meanwhile defining DynamicImport for DBCP does solve the problem for cases where the JDBC driver exports the relevant driver classes but does not (yet) implement a DataSourceFactory service.
          Phil Steitz made changes -
          Field Original Value New Value
          Fix Version/s 1.4.1 [ 12314493 ]
          Hide
          Holger Hoffstätte added a comment - - edited

          The whole purpose of OSGi is to prevent the kind of unfettered access and more or less random class wiring established by DynamicImport; it's a bad practice that should die out. Instead of letting dbcp blindly create instances the right thing to do would be use proper OSGi lookup of a DataSource through an OSGi-aware factory.
          See: http://www.osgi.org/javadoc/r4v42/org/osgi/service/jdbc/DataSourceFactory.html

          Show
          Holger Hoffstätte added a comment - - edited The whole purpose of OSGi is to prevent the kind of unfettered access and more or less random class wiring established by DynamicImport; it's a bad practice that should die out. Instead of letting dbcp blindly create instances the right thing to do would be use proper OSGi lookup of a DataSource through an OSGi-aware factory. See: http://www.osgi.org/javadoc/r4v42/org/osgi/service/jdbc/DataSourceFactory.html
          Felix Mayerhuber created issue -

            People

            • Assignee:
              Unassigned
              Reporter:
              Felix Mayerhuber
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development