Remove deprecated PersistenceProvider from hibernate-entitymanager META-INF/services/javax.persistence.spi.PersistenceProvider
Description
is duplicated by
Activity
Steve EbersoleMarch 10, 2015 at 3:46 PM
Well, I would not say "all we need". Moving forward I think removing the old entry from META-INF/services/javax.persistence.spi.PersistenceProvider
is clearly the right thing to do, for the reasons I outlined above.
Sanne GrinoveroMarch 10, 2015 at 3:43 PM
+1 for https://hibernate.atlassian.net/browse/JPA-67#icft=JPA-67 : all we need is enforce the right order
Steve EbersoleMarch 10, 2015 at 2:02 AM
One thing we can do for 4.3 is https://hibernate.atlassian.net/browse/JPA-67#icft=JPA-67
Steve EbersoleMarch 9, 2015 at 7:53 PM
Discussed this in detail with Scott on IRC. Like I said, I had initially tried to remove org.hibernate.ejb.HibernatePersistence
from Hibernate's META-INF/services/javax.persistence.spi.PersistenceProvider
. That way, the only way it can be used as the provider is deployments which explicitly list that as the provider class : <provider>org.hibernate.ejb.HibernatePersistence</provider>
, in which case the user is CLEARLY specifying the deprecated provider and should be warned.
META-INF/services/javax.persistence.spi.PersistenceProvider
is all about dynamic discovery of providers and resolution of the provider to use in cases where the user did not specify which provider to use. In that case, there is no need for org.hibernate.ejb.HibernatePersistence
to be listed in the service file.
When I originally tried to remove this from the Hibernate service file, it caused problems on WildFly. But in discussing this with Scott, I believe this is actually a problem in WildFly. So, for 5.0 (at least) I plan on removing org.hibernate.ejb.HibernatePersistence
from the service file as the real solution to this.
@Former user We'll have to discuss a proper solution to this for 4.x. I don't think removing the entry is viable option there. Quite possibly the "solution" for 4.x is to wait for 5.0...
Steve EbersoleMarch 9, 2015 at 6:24 PM
@Scott Marlow - Does WildFly actually check that the named provider is "available" itself, rather than delegating the calls to the actual PersistenceProviders loaded? IIRC the issue in WildFLy was related to that. Again, Hibernate's org.hibernate.jpa.HibernatePersistenceProvider
knows to accept <provider>org.hibernate.ejb.HibernatePersistence</provider>
. The only time I can see org.hibernate.ejb.HibernatePersistence
not being listed as a provider via META-INF/services/javax.persistence.spi.PersistenceProvider
is if the environment (WildFly/Jipijapa) forces that issue.
I'm using hibernate 4.3.5.Final (using maven dependencies, and using Tomcat 7.0.47).
Like https://hibernate.atlassian.net/browse/HHH-8625#icft=HHH-8625 I'm using the correct provider in my
META-INF/persistence.xml
:<persistence-unit name="com.iorga.irajblank" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> ...
But I'm getting
avr. 24, 2014 5:01:24 PM org.hibernate.ejb.HibernatePersistence logDeprecation WARN: HHH015016: Encountered a deprecated javax.persistence.spi.PersistenceProvider [org.hibernate.ejb.HibernatePersistence]; use [org.hibernate.jpa.HibernatePersistenceProvider] instead.
I've seen that
hibernate-entitymanager-4.3.5.Final.jar/META-INF/services/javax.persistence.spi.PersistenceProvider
contains those lines :org.hibernate.jpa.HibernatePersistenceProvider # The deprecated provider, logs warnings when used. org.hibernate.ejb.HibernatePersistence
But as in
hibernate-jpa-2.1-api-1.0.0.Final.jar:javax.persistence.spi.PersistenceProviderResolverHolder.PersistenceProviderResolverPerClassLoader.CachingPersistenceProviderResolver.loadResolverClasses(ClassLoader)
those ones are added in a HashSet (usingaddAll
method), when listing them (inhibernate-jpa-2.1-api-1.0.0.Final.jar:javax.persistence.Persistence.getProviders()
),org.hibernate.ejb.HibernatePersistence
is listed first.