junedo / javamelody

Automatically exported from code.google.com/p/javamelody
0 stars 0 forks source link

JPA monitoring to work with eclipse links. #428

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add the monitoring entry to persitence.xml and set provide as eclipse links
   <provider>net.bull.javamelody.JpaPersistence</provider>
<property name="net.bull.javamelody.jpa.provider" 
value="org.eclipse.persistence.jpa.PersistenceProvider" />
2.
3.

What is the expected output? What do you see instead?
The container should start up, it is failing with below error
org.eclipse.persistence.exceptions.PersistenceUnitLoadingException: 
Exception Description: An exception was thrown while searching for persistence 
archives with ClassLoader: 
net.bull.javamelody.JpaOverridePersistenceXmlClassLoader@1c93dc0d
Internal Exception: javax.persistence.PersistenceException: Exception 
[EclipseLink-28018] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): 
org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [DataSrouce] failed.

What version of the product are you using? On what application server, JDK,
operating system?
1.52, Jboss 5.1 and Red had linux

Please provide any additional information below.

Original issue reported on code.google.com by basilabr...@gmail.com on 19 Aug 2014 at 5:07

GoogleCodeExporter commented 9 years ago
What version of eclipse link do you use?
Is it reproduced in a basic eclipse link project?

For information, the relevant javamelody source files are:
- 
https://code.google.com/p/javamelody/source/browse/trunk/javamelody-core/src/mai
n/java/net/bull/javamelody/JpaPersistence.java
- 
https://code.google.com/p/javamelody/source/browse/trunk/javamelody-core/src/mai
n/java/net/bull/javamelody/JpaOverridePersistenceXmlClassLoader.java

Original comment by evernat@free.fr on 19 Aug 2014 at 9:03

GoogleCodeExporter commented 9 years ago
As a wild guess, the specific handling of ClassLoader and of 
getResource("META-INF/persistence.xml") and 
getResources("META-INF/persistence.xml") in javamelody 
JpaOverridePersistenceXmlClassLoader or in Eclipse Link may be related to this 
issue.

Original comment by evernat@free.fr on 19 Aug 2014 at 9:03

GoogleCodeExporter commented 9 years ago
We are using eclipse link 2.4, it is can be easily reproducible  

Original comment by basilabr...@gmail.com on 20 Aug 2014 at 1:41

GoogleCodeExporter commented 9 years ago
Thanks for the info. It confirms the stack-trace indeed.

Do you have the source of a simple webapp project (using Maven if possible), to 
reproduce the issue? Because I currently don't have one.

Of course, it would be even better if you find what is the cause and how to fix 
it.

Original comment by evernat@free.fr on 20 Aug 2014 at 5:29

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
This is due to eclipselink imitialization implementation which resolves content 
of <provider> tag and requires to keep 
org.eclipse.persistence.jpa.PersistenceProvider there. The workaround is wrap 
the DataSource with Javamelody proxy programmatically and transfer to 
persistence provider via the PersistenceUnitProperties.NON_JTA_DATASOURCE 
property:

DataSource dataSourceProxy = 
JdbcWrapper.SINGLETON.createDataSourceProxy("default", realDataSource);
Map<String, Object> props = new HashMap<String, Object>();
props.put(PersistenceUnitProperties.NON_JTA_DATASOURCE, dataSourceProxy);
EntityManagerFactory factory = 
Persistence.createEntityManagerFactory("default", props);

Original comment by Roman.Si...@gmail.com on 23 Aug 2014 at 11:41

GoogleCodeExporter commented 9 years ago
Thanks for the info Roman. But I am a bit lost.

For example, what is the goal to wrap the datasource in a proxy here and to 
transfer it to the persistence provider? Just to have monitoring of sql 
requests?

And what are we supposed to do with the following line:
EntityManagerFactory factory = 
Persistence.createEntityManagerFactory("default", props);
Do you mean that if the monitored application uses that way, it will magically 
work around the above exception?

Or the only solution to not have the above exception is to keep 
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
in persistence.xml instead of
<provider>net.bull.javamelody.JpaPersistence</provider>
?

Original comment by evernat@free.fr on 29 Aug 2014 at 11:31

GoogleCodeExporter commented 9 years ago
There is no simple webapp project to reproduce the issue, and no info on what 
may or may not workaround the issue.
So closing as invalid/incomplete.

Anyone is welcome to submit a simple project to reproduce the issue.

Original comment by evernat@free.fr on 16 Nov 2014 at 4:22