0

I have a maven application running on JBoss EAP 7.2 . Below details:

  • Build: Maven 3.6
  • Server: JBoss EAP 7.2
  • Java: OpenJDK 11
  • JavaMelody Core: 1.83.0
  • Package: EAR
  • Application: Struts 2.5.22
  • DB: Oracle 18c
  • OJDBC Driver: 18.3

Although I managed to configure JavaMelody and see the main statistics, I can't seem to find a way to configure the SQL monitoring.

Currently, for my JDBC configuration I use the <jta-data-source>java:jboss/datasources/myDS</jta-data-source> in my persistence.xml file, which reads the datasource from the standalone.xml of the JBoss server.

I have tried several changes in my persistence.xml file like adding:

<property name="net.bull.javamelody.jpa.provider" value="org.hibernate.jpa.HibernatePersistenceProvider" />

or

<property name="hibernate.connection.driver_class" value="net.bull.javamelody.JdbcDriver"/>

My struts.xml configuration:

<package name="myApp" extends="struts-default">
    <interceptors>
        <interceptor name="monitoring" class="net.bull.javamelody.StrutsInterceptor"/>
        <interceptor-stack name="myAppStack">
            <interceptor-ref name="monitoring"/>
            <interceptor-ref name="prepare"/>
            ...
            <interceptor-ref name="json"/>
            <interceptor-ref name="debugging"/>
            <interceptor-ref name="defaultStack"/>
        </interceptor-stack>
    </interceptors>
    <default-interceptor-ref name="myAppStack"/>
</package>

or even configuring my datasource entirely in the persistence file using the hibernate.connection.url/username/password properties, but with no luck.

I tried to following the instructions found here, but I can't seem to find what is wrong:

Note: In my persistence.xml I was using also <property name="hibernate.connection.driver" value="oracle.jdbc.OracleDriver" /> . I am not sure if this is somehow conflicting.

StackzOfZtuff
  • 2,534
  • 1
  • 28
  • 25
Stephan
  • 696
  • 15
  • 37

1 Answers1

1

JPA monitoring is completely different than SQL monitoring: do not try net.bull.javamelody.jpa.provider to monitor SQL. And it is useless to try hibernate.connection.driver_class if you use a datasource from JNDI.

For SQL monitoring, you can try to monitor SQL from the datasource in JNDI:

  • either add a javamelody parameter datasource, for example with a system property: -Djavamelody.datasources=java:jboss/datasources/myDS
  • or rename your datasource to java:jdbc/myDS

Then check the "Debugging logs" at the bottom of the javamelody reports.

And because you are using an EAR, see https://github.com/javamelody/javamelody/wiki/UserGuideAdvanced#setup-javamelody-in-an-ear-file

evernat
  • 1,713
  • 13
  • 18
  • 1 ) On my first attemp with JBoss EAP 6 and following also this https://stackoverflow.com/a/56401927/1918516 i remember i managed to make Java Melody work. Now although i am able to acces to report site, in my logs i see: java.lang.NoClassDefFoundError: Failed to link net/bull/javamelody/StrutsInterceptor 2) Thank you for your help. The argument did the trick for the SQL ! – Stephan Jun 01 '20 at 13:19
  • The NoClassDefFoundError: Failed to link net/bull/javamelody/StrutsInterceptor is certainly caused by the EAR packaging and perhaps because struts2-core is not in the same classloader as javamelody. So Struts monitoring is not possible in this case. – evernat Jun 01 '20 at 15:08
  • So after all i cannot use JavaMelody with Struts and EAR packaging if i understand correct or it can be stil configured? Since my struts and javamelody dependency are under the same war module contained in the EAR, shouldn't they interact with the same classloader ? – Stephan Jun 02 '20 at 04:46
  • 1
    As far as I know, you can use javamelody with Struts and EAR packaging. If "NoClassDefFoundError: Failed to link net/bull/javamelody/StrutsInterceptor" is an issue and if it doesn't work in this EAR, just don't use the javamelody StrutsInterceptor in your Struts configuration. – evernat Jun 03 '20 at 16:36