JMonitoringFAQ


I never had any flow in database after executing my code

JMonitoring

  • Check if your code is really weaved, you can use Jad to check if the byte code really has reference to AspectJ.
    A class that is weaved has these imports:
    import org.aspectj.lang.JoinPoint;
    import org.aspectj.runtime.internal.AroundClosure;
    import org.aspectj.runtime.reflect.Factory;
    import org.jmonitoring.core.aspects.PerformanceAspect;
    import org.jmonitoring.core.common.MeasureException;
    import org.jmonitoring.core.dto.MeasurePointManager;
    

    If you code in not weaved check your process with Weave your Application.

Your will then find more information in the log file specified with your log4j configuration file.
When JMonitoring can't inserty [Flows] into the [Datastore], there isn't any error into your application for avoiding the interuption of your business. You need to look at the log file to understand the troubles.

NMonitoring

Your will then find more information in the log file specified with your log4net configuration file
When NMonitoring can't inserty [Flows] into the [Datastore], there isn't any error into your application for avoiding the interuption of your business. You need to look at the log file to understand the troubles.

QQQ : log4net not already used !

JMonitoring Console

How configure Hibernate for SQLServer

Edit the 'hibernate.cgf.properties' and use these settings:

hibernate.connection.driver_class=net.sourceforge.jtds.jdbc.Driver
hibernate.dialect=org.hibernate.dialect.SQLServerDialect
hibernate.connection.url=jdbc:jtds:sqlserver://localhost:1433/jmonitoring
hibernate.connection.username=jmonitoring
hibernate.connection.password=jmonitoring
hibernate.show_sql=true
#hibernate.connection.autocommit=true
hibernate.jdbc.batch_size=30

Which license is use by JMonitoring and NMonitoring ?

GNU LESSER GENERAL PUBLIC LICENSE, see License.

How to trace JDBC Acess when our application is using Hibernate

JMonitoring

I should weave the Hibernate code with this aspect:

package org.jmonitoring.core.sample;
import org.jmonitoring.core.aspects.PerformanceAspect;
public aspect JdbcAspect extends PerformanceAspect {
	public pointcut executionToLog() : (call (* java.sql.Connection+.prepare*(..))
		|| call (* java.sql.Statement+.execute*(..)));

    public JdbcAspect()
    {
        mGroupName = "JDBC";
    }
}

For weaving Hibernate I can weave it at runtime if you use jdk1.5+ or with it at compile time.
For compile time weaving you should

  • Get the Hibernate source
  • Change the build.xml file
    • Add JMonitoring classpaths
      	<path id="lib.class.path">
      		<fileset dir="${lib.dir}">
      			<include name="**/*.jar"/>
      		</fileset>
      		<pathelement path="${clover.jar}"/>
      
      		<!-- JOMNI -->
          <pathelement location="${libdir}/jmonitoring/jars/core_monitoring-1.0-SNAPSHOT.jar"/>
          <pathelement location="${libdir}/junit/jars/junit-3.8.1.jar"/>
          <pathelement location="${libdir}/jmock/jars/jmock-1.0.1.jar"/>
          <pathelement location="${libdir}/log4j/jars/log4j-1.2.8.jar"/>
          <pathelement location="${libdir}/commons-logging/jars/commons-logging-1.0.4.jar"/>
          <pathelement location="${libdir}/aspectj/jars/aspectjtools-1.5.0.jar"/>
          <pathelement location="${libdir}/aspectj/jars/aspectjrt-1.5.0.jar"/>
          <pathelement location="${libdir}/mysql/jars/mysql-connector-java-3.1.11-bin.jar"/>
          <pathelement location="${libdir}/commons-configuration/jars/commons-configuration-1.1.jar"/>
          <pathelement location="${libdir}/commons-lang/jars/commons-lang-2.0.jar"/>
          <pathelement location="${libdir}/commons-collections/jars/commons-collections-3.1.jar"/>
      	</path>
      
    • Declare AjcAntTask
        <taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
          <classpath>
            <pathelement location="${libdir}/aspectj/jars/aspectjtools-1.5.0.jar"/>
          </classpath>
        </taskdef>
      
    • Replace the JavaC Task with AJC
      <!--javac
      			destdir="${classes.dir}"
      			classpathref="lib.class.path"
      			debug="${javac.debug}"
      			optimize="${javac.optimize}"
      			nowarn="on">
      			<src path="${src.dir}"/>
      			<src path="${generated.src}"/>
      		</javac-->
      		<!-- JMONI -->
      
          <iajc destDir="${classes.dir}" deprecation="true" debug="${javac.debug}" excludes="**/package.html">
            <sourceroots>
              <pathelement location="${src.dir}"/>
              <pathelement location="${generated.src}"/>
            </sourceroots>
            <aspectpath>
          		<!--pathelement location="${libdir}/jmonitoring/jars/core_monitoring-0.5dev.jar"/-->
      				<pathelement location="D:/apisbench/JMonitoringAspects/target/JMonitoringAspects.jar"/>
            </aspectpath>
            <classpath refid="lib.class.path"/>
          </iajc>
      

JMonitoring and WebSphere

With WebSphere 6.1, I have an error during the execution of my application,

java.lang.NoSuchMethodError: org/aspectj/runtime/reflect/Factory.makeMethodSig(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lorg/aspectj/lang/reflect/MethodSignature;

This is due to the AspectJ runtime bundle with WebSphere (an old version).
You have to add this option to your AspectJ compiler : X="ajruntimetarget:1.2"

Exemple with ANT :

<iajc X="ajruntimetarget:1.2"
sourceroots="src" source="1.5" classpath="d:/aspectj1.6-dev/lib/aspectjrt.jar"/>

More information on this forum.

What is the overhead ?

JMonitoring

Overhead of the JMonitoring framework

QQQ

Overhead of the Hibernate/Jdbc aspect

QQQ

NMonitoring

QQQ

How can we have the time spent into the Jsp/Asp

JMonitoring

At Jsp level

If you use aspects at compile time, your Jsp (compiled by the container) page won't be weaved.

  1. You should pre-compile your Jsp (see http://ant.apache.org/manual/OptionalTasks/jspc.html or the documentation of your container).
  2. You may should disable the Jsp container recompilation
  3. You have to weave you jsp classes with your aspect using Ant
    ANT Sample
    <target name="weavePage" >
        <delete dir="${destDir}" />
        <mkdir dir="${destDir}"/>
        <copy todir="${destDir}" >
            <fileset dir="${fromDir}" excludes="class"/>
        </copy>
        <iajc destDir="${destDir}" deprecation="false" debug="true">
            <inpath>
                <pathelement location="${fromDir}"/>
            </inpath>
            <aspectpath>
                <pathelement location="${myAspect.jar}"/>
            </aspectpath>
            <classpath refid="OCTOclassPath"/>
        </iajc>
    </target>
    

At Struts level

You can override the Struts default ActionSevlet and define an aspect for Weaving all the Struts calls.

org.jmonitoring.servlet.JMonitoringActionServlet
package org.jmonitoring.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import org.apache.struts.action.ActionServlet;

public class JMonitoringActionServlet extends ActionServlet {
	public void service(ServletRequest arg0, ServletResponse arg1) throws ServletException, IOException {
		super.service(arg0, arg1);
	}
}
ServletAspect
package com.jmonitoring.aspects;

import org.jmonitoring.core.aspects.PerformanceAspect;
import org.jmonitoring.core.info.impl.DefaultExceptionTracer;

public aspect ServletAspect extends PerformanceAspect {

	public pointcut executionToLog() : (
				execution( * javax.servlet.http.HttpServlet+.*(..))
				);

	public ServletAspect() {
		mParamTracer = null;
		mResultTracer = null;
		mThowableTracer = new DefaultExceptionTracer();
		mGroupName = "Servlet";
	}
}

And finally define you new Servlet instead of the default Struts servlet in your web.xml file.

web.xml
    <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>org.jmonitoring.servlet.JMonitoringActionServlet</servlet-class>
        ...
    </servlet>

NMonitoring

QQQ You should put a trigger on Page (pre_init() and QQQ) event...

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.