Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-2573

DI field injection is triggered when creating sql Driver

    XMLWordPrintableJSON

    Details

      Description

      Some of DataSourceFactory implementations (namely DriverDataSourceFactory, PropertyDataSourceFactory and XMLPoolingDataSourceFactory) useĀ AdhocObjectFactory to create Driver instance. This have one nasty side effect: DI field injection is used in a process and it can lead to errors.

      This is an exception that is thrown by SAP HANA driver in that case:

      java.lang.NoClassDefFoundError: Ljava/lang/ref/Cleaner;
      
      	at java.lang.Class.getDeclaredFields0(Native Method)
      	at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
      	at java.lang.Class.getDeclaredFields(Class.java:1916)
      	at org.apache.cayenne.di.spi.FieldInjectingProvider.injectMembers(FieldInjectingProvider.java:55)
      	at org.apache.cayenne.di.spi.FieldInjectingProvider.get(FieldInjectingProvider.java:44)
      	at org.apache.cayenne.di.spi.DefaultAdhocObjectFactory.newInstance(DefaultAdhocObjectFactory.java:70)
      

      I believe we should use only getJavaClass() method of AdhocObjectFactory. As a more distant solution we can check usage of DriverManager instead of detecting and using Driver explicitly.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ntimofeev Nikita Timofeev
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: