Uploaded image for project: 'Java Persistence API'
  1. JPA-65

Duplicate PersistenceProvider registration

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects versions: None
    • Fix versions: None
    • Labels:
      None
    • Environment:
      Java 8, Hibernate 4.3.6.Final, jpa-2.1-1.0.0
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Suitable for new contributors:
      Yes, likely
    • Last commented by a user?:
      true
    • Sprint:

      Description

      I've noticed a bug in the

      javax.persistence.spi.PersistenceProviderResolverHolder.PersistenceProviderResolverPerClassLoader

      Class which results in two instances of the

      org.hibernate.jpa.HibernatePersistenceProvider

      to be available at runtime (as well as the deprecated ejb instance, which is always move to first position).

      I've highlighted the lines which cause the problem Persistence Proivder

      During execution under Java 7, the implementation of hash set results in an iteration over the list of providers in the META-INF/services file which has the org.hibernate.ejb.HibernatePersistence first, which avoid the bug.

      In Java 8 this order has changed and results in the org.hibernate.jpa.HibernatePersistenceProvider being the first item in the iterator.

      The duplicate is added if the org.hibernate.jpa.HibernatePersistenceProvider is the first element in the iterator, as this then passes the condition to manage the org.hibernate.ejb.HibernatePersistence to be first in the list. This is where the extra is added, as all that is needed to complete correctly and force the ejb version to be first is line 148. Line 149 adds a copy of the binding previously at position 0 at the end of the list. Lines 147 & 149 should be removed to resolve the problem.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: