Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lack of Jpa statistics (depending on installation procedure) #750

Closed
eetievent opened this issue Jun 13, 2018 · 6 comments
Closed

Lack of Jpa statistics (depending on installation procedure) #750

eetievent opened this issue Jun 13, 2018 · 6 comments

Comments

@eetievent
Copy link

eetievent commented Jun 13, 2018

What steps will reproduce the problem?

For an application using EclipseLink Jpa, install JavaMelody, either with the jars, or already included in the application war.

What is the expected output? What do you see instead?

The monitoring page should display the "Statistics Jpa" block, and on some installations it doesn't.
Note that the logs should display the second line, and on theses installations it doesn't:

(application log) - Creating EntityManagerFactory acdConfig
net.bull.javamelody - jpa persistence initialized

Procedure to activate the Jpa statistics in case they are not - case JavaMelody jars

stop Tomcat, suppress javamelody and jrobin jars, start tomcat, wait for application start (at least Jpa initialisation), add the jars (do not add them before...), restart Tomcat
Just restarting Tomcat doesn't change the situation.

Procedure to activate the Jpa statistics in case it's not - case embedded in war (web.xml)

stop Tomcat, copy the application war in webapps, start tomcat
(do not undeploy the war, or delete the deployed directory)

Application setup

The application uses 4 EntityManagerFactory (javax.persistence):

  this.entityManagerFactory = Persistence.createEntityManagerFactory(PERSISTENCE_PROVIDER_NAME, properties);

In the case JavaMelody is embedded in the application war, here is web.xml:

	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>
			classpath:net/bull/javamelody/monitoring-spring.xml
			/WEB-INF/classes/applicationContext.xml
		</param-value>
	</context-param>

applicationContext.xml:

	<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator">
	   <property name="proxyTargetClass" value="true"/>
	</bean>
	<bean id="facadeMonitoringAdvisor" class="net.bull.javamelody.MonitoringSpringAdvisor">
		<property name="pointcut">
			<bean class="net.bull.javamelody.MonitoredWithInterfacePointcut">
				<property name="interfaceName" value="...." />
			</bean>
		</property>
	</bean>

What version of the product are you using? On what application server, JDK, operating system?

Ubuntu Xenial 16.04 Lts
openjdk 1.8.0_171
Tomcat 8.0.37
EclipseLink Jpa 2.7.0
JavaMelody 1.71.0

Did I miss something?

Thanks a lot for JavaMelody!

@evernat
Copy link
Member

evernat commented Jun 16, 2018

Can you give the source of a simple project to reproduce the issue?

@evernat
Copy link
Member

evernat commented Jul 1, 2018

Any news?

@eetievent
Copy link
Author

It looks quite difficult to extract a simple project from the project I work on... Can I try something simpler before that? As a first step, maybe I could activate some debug logs with log4j that could give you a direction to check? (on some specific packages: JavaMelody and Jpa initialisation)
Also, if somebody gets the same problem, he can follow the procedure above to make it work...
Thank you.

@evernat
Copy link
Member

evernat commented Jul 9, 2018

I have read again this issue carefully.

Procedure to activate the Jpa statistics in case they are not - case JavaMelody jars

I don't know exactly what you mean by "case JavaMelody jars", but if it is putting the 2 javamelody jar files in the tomcat/lib directory, then you should know that it is not recommended and not really supported.

Procedure to activate the Jpa statistics in case it's not - case embedded in war (web.xml)
stop Tomcat, copy the application war in webapps, start tomcat

It's good if it works that way because it seems that it's the standard procedure for javamelody (ie include the 2 javamelody jar files in the war of the webapp and copy the war in tomcat/webapps).

So what is the problem in fact?

@eetievent
Copy link
Author

eetievent commented Jul 10, 2018

Procedure to activate the Jpa statistics in case they are not - case JavaMelody jars

I copied the jars to the tomcat/webapps//WEB-INF/lib directory. The reason is that I tried to use JavaMelody on a application before we can upgrade it to a new version with JavaMelody embedded in the war. I misinterpreted the doc and thought we could install the jars in the directory deployed from the war (instead of the war). So I understand this is not really supported too.
(by the way, I've just tried to copy the jars to tomcat/lib, and that causes an exception and failure, because the Tomcat class loader doesn't have access to the application classes, which are handled by the application class loader)

Procedure to activate the Jpa statistics in case it's not - case embedded in war (web.xml)

If we don't restart tomcat but just undeploy / deploy the application instead, then we have the Jpa problem. So it's a matter of doing the right procedure.

Thank you

@evernat
Copy link
Member

evernat commented Dec 30, 2018

If we don't restart tomcat but just undeploy / deploy the application instead, then we have the Jpa problem.
So it works when restarting tomcat (and not when doing hot undeploy / deploy). And that's enough for me given that I probably can't do better.

In fact, EclipseLink does not want that <provider>net.bull.javamelody.JpaPersistence</provider> is added in the persistence.xml file like it would need to be (as the last time I checked). So, the only way is that the META-INF/services/javax.persistence.spi.PersistenceProvider file from javamelody is found before the META-INF/services/javax.persistence.spi.PersistenceProvider file from eclipselink. And undeploy / deploy may change something in that order unfortunately.

By the way, I have seen that eclipselink-2.7.0.jar contains the classes of a JPA API. So I suggest, that you don't add another JPA API dependency in your webapp by yourself (having 2 JPA API may influence JPA loading and persistence).

So, given that EclipseLink doesn't cooperate much for injecting the javamelody persistence provider and given that the JPA monitoring works when restarting tomcat, that's enough for me given that I probably can't do better.
And so, fixing the JPA monitoring when using EclipseLink and hot undeploy / deploy instead of restart is certainly won't fix. Sorry.

@evernat evernat closed this as completed Dec 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants