Announcement Announcement Module
No announcement yet.
Logging and AOP Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Logging and AOP

    I am a newbie to AOP. I am trying to implement trace logging, where I would like to log the entry and exit of every method.

    for that i have written

    public class TraceLoggingAspect {

    TraceLogger logger;

    public TraceLoggingAspect()
    logger=new TraceLogger();

    @Pointcut("execution(* *(..))")
    public void eachMethod(){}

    public void log(ProceedingJoinPoint joinpoint)
    String logID=System.nanoTime()+"";
    logger.debug(logID, "Entering method.."+joinpoint.getSignature());

    logger.debug(logID, "Exiting method.."+joinpoint.getSignature());
    catch (Throwable e)
    logger.error(logID, e.getMessage(),e);


    and have used <aop:aspectj-autoproxy/> in my appliaction-config.xml to create auto proxy.

    Nothing is getting logged into the trace file. I might be missing something very basic...can someone throw light.

  • #2
    Actually, I didnt declare the bean definition for the aspect.

    So now I added the following bean definition to my config file...

    <bean name="traceLoggingAspect" class="com.bcbsnc.rdb.logging.TraceLoggingAspect"/>

    Now , I run into a different issue...

    org.springframework.beans.factory.BeanCurrentlyInC reationException: Error creating bean with name 'sessionFactory': Bean with name 'sessionFactory' has been injected into other beans [transactionManager] in its raw version as part of a circular reference, but has eventually been wrapped (for example as part of auto-proxy creation). This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example.
    at AutowireCapableBeanFactory.createBean(AbstractAuto
    at BeanFactory$1.getObject( 49)
    at ingletonBeanRegistry.getSingleton(DefaultSingleton
    at BeanFactory.getBean(

    and these are the bean definitions

    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
    <property name="dataSource" ref="rdbDataSource" />
    <property name="mappingLocations">
    <property name="hibernateProperties">

    <bean id="rdbDataSource" class="" destroy-method="close" lazy-init="true">
    <property name="serverName" value="" />
    <property name="portNumber" value="50000" />
    <property name="databaseName" value="RNCDU01" />
    <property name="cliSchema" value="RDB" />
    <property name="user" value="db2admin" />
    <property name="password" value="itpc" />
    <property name="currentSchema" value="RDB" />
    <property name="driverType" value="4" />

    <!-- Instructs the container to look for beans with @Transactional and decorate them -->
    <tx:annotation-driven transaction-manager="transactionManager" />

    <!-- A transaction manager for working with Hibernate SessionFactories -->
    <bean id="transactionManager"
    class="org.springframework.orm.hibernate3.Hibernat eTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />

    Please help....


    • #3
      If i remove the apsectj configuration from the configuration file..i dont get the error.

      Looks like there is an issue with the annotation based use of aop and transactions.... can anyone help


      • #4
        You can also refer to the logging example featured in Mark Fisher's Blog