You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sirona.apache.org by Vernat Emeric <ev...@free.fr> on 2015/03/22 00:27:38 UTC
About guessing the JPA PersistenceProvider in SironaPersistence
Hi Sirona and JavaMelody devs,
In the Sirona JPA monitoring, inside SironaPersistence [1], the
PersistenceProvider is guessed by trying to load the classes of 11
possible providers:
org.apache.openjpa.persistence.PersistenceProviderImpl,
org.hibernate.jpa.HibernatePersistenceProvider, etc
The one which is found by the ClassLoader wins.
The JavaMelody JPA monitoring was heavily inspired by Sirona's one as
you probably know [2].
My question is: would it be possible and simpler for SironaPersistence
to look into
javax.persistence.spi.PersistenceProviderResolverHolder.getPersistenceProviderResolver().getPersistenceProviders()
instead of loading the classes of providers?
By the way, it seems to me that this change would fix a usage "issue"
with WildFly 8.2 because in WildFly, by default:
- Thread.currentThread().getContextClassLoader() does not find the
org.hibernate.jpa.HibernatePersistenceProvider class from the WildFly
JBoss module,
- while
PersistenceProviderResolverHolder.getPersistenceProviderResolver().getPersistenceProviders()
returns something like [org.apache.sirona.jpa.SironaPersistence@20abb1,
org.hibernate.jpa.HibernatePersistenceProvider@e7f394,
org.hibernate.ejb.HibernatePersistence@28b99c].
(Otherwise, you could read the very long WildFly documentation, or to
keep it short you can certainly add a META-INF/MANIFEST.MF file in the
webapp resources with "Dependencies: org.hibernate")
Thanks guys and girls,
- Emeric
[1]
http://svn.apache.org/repos/asf/incubator/sirona/trunk/agent/performance/jpa/src/main/java/org/apache/sirona/jpa/SironaPersistence.java
[2]
https://code.google.com/p/javamelody/wiki/UserGuideAdvanced#JPA_monitoring
Re: About guessing the JPA PersistenceProvider in SironaPersistence
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi Emeric,
good point, can be a better default but we still need our hardcoded list
for case where resolver is not correctly initialized or not yet initialized.
https://issues.apache.org/jira/browse/SIRONA-44
Thanks for this enhancement!
Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> | Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>
2015-03-22 0:27 GMT+01:00 Vernat Emeric <ev...@free.fr>:
> Hi Sirona and JavaMelody devs,
>
> In the Sirona JPA monitoring, inside SironaPersistence [1], the
> PersistenceProvider is guessed by trying to load the classes of 11 possible
> providers: org.apache.openjpa.persistence.PersistenceProviderImpl,
> org.hibernate.jpa.HibernatePersistenceProvider, etc
> The one which is found by the ClassLoader wins.
> The JavaMelody JPA monitoring was heavily inspired by Sirona's one as you
> probably know [2].
>
> My question is: would it be possible and simpler for SironaPersistence to
> look into javax.persistence.spi.PersistenceProviderResolverHolder.
> getPersistenceProviderResolver().getPersistenceProviders() instead of
> loading the classes of providers?
>
>
> By the way, it seems to me that this change would fix a usage "issue" with
> WildFly 8.2 because in WildFly, by default:
> - Thread.currentThread().getContextClassLoader() does not find the
> org.hibernate.jpa.HibernatePersistenceProvider class from the WildFly
> JBoss module,
> - while PersistenceProviderResolverHolder.getPersistenceProviderResolver().getPersistenceProviders()
> returns something like [org.apache.sirona.jpa.SironaPersistence@20abb1,
> org.hibernate.jpa.HibernatePersistenceProvider@e7f394, org.hibernate.ejb.
> HibernatePersistence@28b99c].
> (Otherwise, you could read the very long WildFly documentation, or to keep
> it short you can certainly add a META-INF/MANIFEST.MF file in the webapp
> resources with "Dependencies: org.hibernate")
>
> Thanks guys and girls,
> - Emeric
>
> [1] http://svn.apache.org/repos/asf/incubator/sirona/trunk/
> agent/performance/jpa/src/main/java/org/apache/sirona/
> jpa/SironaPersistence.java
> [2] https://code.google.com/p/javamelody/wiki/UserGuideAdvanced#JPA_
> monitoring
>
>
>