Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-2915

commons-dbcp2 2.10.0 breaks OpenJPA because of changed configuration methods

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.2.2
    • 3.2.3, 4.0.0
    • third-party

    Description

      When upgrading commons-dbcp2 to the latest version 2.10.0, OpenJPA fails with exceptions when it tries to provide options to commons-dbcp2.

      It seems this happens because dbcp2 moved from Integer-Duration to using java.time.Duration.

      See https://github.com/apache/commons-dbcp/commit/93207813fd6b6c0230cfcebb0e9f5b19e9fa72b9

      It seems that even though the change in dbcp2 was done in a backwards-compatible way, the automatic configuration handling in OpenJPA stumbles and throws an exception when latest commons-dbcp2 (and commons-pool2) are used:

      Caused by: org.apache.openjpa.lib.util.ParseException: org.apache.commons.dbcp2.BasicDataSource@72eed4db.MaxWait = 10000
      	at app//org.apache.openjpa.lib.util.Options.setInto(Options.java:234)
      	at app//org.apache.openjpa.lib.util.Options.setInto(Options.java:187)
      	at app//org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:502)
      	at app//org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:456)
      	at app//org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:436)
      	at app//org.apache.openjpa.lib.conf.Configurations.newInstance(Configurations.java:169)
      	at app//org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:112)
      	... 63 more
      Caused by: org.apache.openjpa.lib.util.ParseException: Error initializing configuration. Failed to create an instance of class java.time.Duration for plugin property 10000.
      	at app//org.apache.openjpa.lib.util.Options.stringToObject(Options.java:449)
      	at app//org.apache.openjpa.lib.util.Options.setInto(Options.java:226)
      	... 69 more
      Caused by: java.lang.ClassNotFoundException: 10000
      	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
      	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
      	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:527)
      	at java.base/java.lang.Class.forName0(Native Method)
      	at java.base/java.lang.Class.forName(Class.java:315)
      	at org.apache.openjpa.lib.util.Options.stringToObject(Options.java:446)
      	... 70 more
      

       

      It should be possible to reproduce with a small OpenJPA sample project and adding the following two newer Gradle dependencies:

      implementation 'org.apache.commons:commons-dbcp2:2.10.0'
      implementation 'org.apache.commons:commons-pool2:2.11.1'

       

      Edit: Fixed version to "2.10.0"

      Attachments

        Issue Links

          Activity

            People

              solomax Maxim Solodovnik
              dominik.stadler@gmx.at Dominik Stadler
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: