javamelody / liferay-javamelody

JavaMelody plugin for Liferay
Apache License 2.0
6 stars 8 forks source link

Optional import of org.apache.naming.factory #15

Closed adrianrm closed 4 years ago

adrianrm commented 4 years ago

Added org.apache.naming.factory as an optional import to Import-Package

Allows JDBC monitoring in Tomcat in an OSGi environment (Liferay 7+). Probably, for other application servers, another package has to be imported.

The class org.apache.naming.factory.ResourceLinkFactory is loaded via reflection to obtain the DataSource registered in JNDI.

In order for this to work, the Portal Property module.framework.system.packages.extra must be modified to contain the package org.apache.naming.factory

evernat commented 4 years ago

Hi Adrian, OK. Thanks for the PR. But there is a doc about JDBC monitoring: https://github.com/javamelody/javamelody/wiki/LiferayPlugin#sql-monitoring Is this doc still needed with this pull request? Or is it not fully needed and a simple <Resource /> tag is enough for a portlet perhaps?

By the way, on another subject, does a similar import allows to load the class net.sf.ehcache.management.CacheStatistics from Liferay 7.2 DXP SP1 and from Liferay CE portal 7.3.0 GA1 ? This would allow the javamelody plugin to display caches from Liferay (issue #14).

adrianrm commented 4 years ago

Hello, the document about JDBC monitoring still applies, but it has to be updated for Liferay Portal 7+.

Can you show me an example of the <Resource /> tag? I will test how it works in my DXP 7.0.

About the caches: In my installed bundle (Again DXP 7.0), there is this imported package: net.sf.ehcache.management; version="2.10.6" <com.liferay.portal.cache.ehcache.provider_2.0.10 [146]>

So, perhaps the new EHCache Bundle does not export the package? I will have a look another time.

evernat commented 4 years ago

the document about JDBC monitoring still applies, but it has to be updated for Liferay Portal 7+.

OK, Let us know what can be changed in the doc, because I have no idea.

Can you show me an example of the tag? I will test how it works in my DXP 7.0.

I thought for a second that it may be possible to add a <Resource /> tag in the META-INF/context.xml in the portlet or in $TOMCAT_HOME/conf/context.xml like the following, without using GlobalNamingResources.

    <!-- Example using the MySQL database -->
    <Resource name="jdbc/LiferayPool" auth="Container" type="javax.sql.DataSource" defaultAutoCommit="false"
        url="jdbc:mysql://localhost:3306/lportal?useUnicode=true&amp;characterEncoding=UTF-8"
        driverClassName="com.mysql.jdbc.Driver"
        username="root" password=""
        maxTotal="20" maxIdle="10" maxWait="10000"
    />

(But examples on Internet suggest that it is needed for Liferay to use ResourceLink and GlobalNamingResources as said in doc.)

So, perhaps the new EHCache Bundle does not export the package? I will have a look another time.

OK, let us know.

evernat commented 4 years ago

PR merged for 1.83 release. I would still be interested by the changes in doc. And imports for ehcache if you can.

adrianrm commented 4 years ago

How is the best way to make changes in the documentation? I made a copy of the wiki page in https://github.com/adrianrm/javamelody/wiki/LiferayPlugin and made my changes on it. You could just get the contents from there.

I don't think I can investigate the EHCache problem right now. Sorry

evernat commented 4 years ago

The doc is merged: https://github.com/javamelody/javamelody/wiki/LiferayPlugin#sql-monitoring Thank you. By the way, you can find the 1.83.0 release at https://github.com/javamelody/liferay-javamelody/releases and in the Liferay marketplace probably in a few days.