Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Global tracing

  1. #1
    Join Date
    Aug 2004
    Location
    Atlanta, GA
    Posts
    129

    Default Global tracing

    Is there a way I can configure Spring AOP to allow printing of entry and exit of methods for multiple classes without defining individual proxies for each one?
    Randy

  2. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    Yes. You can use BeanNameAutoProxyCreator to apply the Trace Advisor. BeanNameAutoProxyCreator can proxy singletons as well as prototypes.
    HTH
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    Or another "auto proxy creator" like DefaultAdvisorAutoProxyCreator. This looks at all Advisors defined in your context, and checks whether the pointcut matches each bean defined.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

  4. #4
    Join Date
    Aug 2004
    Location
    Atlanta, GA
    Posts
    129

    Default

    I'm trying to use the DefaultAdvisorAutoProxyCreator as such:
    Code:
     
        <bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"/> 
    
        <bean id="tracingBeforeAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor"> 
            <property name="pattern"><value>.*</value></property> 
            <property name="advice"><bean class="com.test.service.audit.TraceBeforeAdvice"/></property> 
        </bean>
    TraceBeforeAdvice is the same as the Spring TraceInterceptor, but logs input arguments as well. When I add these beans, I get the following exception first thing:

    Code:
    org.springframework.beans.TypeMismatchException&#58; Failed to convert property value of type &#91;$Proxy40&#93; to required type &#91;com.test.data.jdbc.AppConfigJdbcImpl&#93; for property 'appConfig' 
       at org.springframework.beans.BeanWrapperImpl.doTypeConversionIfNecessary&#40;BeanWrapperImpl.java&#58;1010&#41; 
       at org.springframework.beans.BeanWrapperImpl.setPropertyValue&#40;BeanWrapperImpl.java&#58;772&#41;
    I can provide a longer stack trace if that would help. The AppConfig bean is the first one created and being injected. I'm using 1.2RC2. My property takes the interface (com.test.data.AppConfig). I took what I found in the reference docs and Pro Spring, but probably made a mistaken assumption in filling in the blanks. Are there any examples of application-wide (all classes/all methods) tracing using AOP in any of the projects or sub-projects? I checked the samples and didn't see anything.

    The app works fine without it.

    Thanks in advance.
    Randy

  5. #5
    Join Date
    Jan 2006
    Posts
    26

    Default

    did you find a solution for your problem? Please let me know. Iam interested.

  6. #6
    Join Date
    Nov 2005
    Location
    Chicago
    Posts
    122

    Default

    Are you using com.xxx.AppConfigJdbcImpl as the parameter type for the setAppConfig() method? You should instead have an interface, namely AppConfig and then have AppConfigJdbcImpl implement this interface. It looks like a JDK-proxy (which implements interfaces) and you are asking for a specific implementation.

    Jess

  7. #7
    Join Date
    May 2005
    Location
    Bucharest/Romania
    Posts
    14

    Default

    I am wondering if adding cglib would solve this?

  8. #8
    Join Date
    Dec 2005
    Posts
    4

    Default Resolved?

    Did anyone find out what the cause of this is?

    I am trying to do the same thing, using BeanNameAutoProxyCreator, and getting the same error. The proxy creator is applying enter/exit tracing to methods, and also logging exceptions to a particular log.

    Code:
    Code:
           <bean id="proxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
           		<property name="beanNames">
           			<list>
           				<value>*</value>
           			</list>
           		</property>
           		<property name="interceptorNames">
           			<list>
           				<value>loggingThrowsAdvice</value>
           				<value>tracingBeforeAdvice</value>
           				<value>tracingAfterAdvice</value>
           			</list>
           		</property>
           </bean>
           
           <!-- Advice -->
           <bean id="loggingThrowsAdvice" class="com.nike.gtcustoms.business.LoggingThrowsAdvice"/>
           <bean id="tracingBeforeAdvice" class="com.nike.gtcustoms.business.TracingBeforeAdvice"/>
           <bean id="tracingAfterAdvice" class="com.nike.gtcustoms.business.TracingAfterAdvice"/>
    The full stack trace looks like this:
    Code:
    2006-03-06 10:42:07,739 ERROR org.springframework.web.context.ContextLoader - Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: At least one handler method must be found in class [class $Proxy0]
    java.lang.IllegalArgumentException: At least one handler method must be found in class [class $Proxy0]
    	at org.springframework.aop.framework.adapter.ThrowsAdviceInterceptor.<init>(ThrowsAdviceInterceptor.java:86)
    	at org.springframework.aop.framework.adapter.ThrowsAdviceAdapter.getInterceptor(ThrowsAdviceAdapter.java:41)
    	at org.springframework.aop.framework.adapter.DefaultAdvisorAdapterRegistry.getInterceptors(DefaultAdvisorAdapterRegistry.java:77)
    	at org.springframework.aop.framework.AdvisorChainFactoryUtils.calculateInterceptorsAndDynamicInterceptionAdvice(AdvisorChainFactoryUtils.java:77)
    	at org.springframework.aop.framework.HashMapCachingAdvisorChainFactory.getInterceptorsAndDynamicInterceptionAdvice(HashMapCachingAdvisorChainFactory.java:47)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:156)
    	at $Proxy2.getConnection(Unknown Source)
    	at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:81)
    	at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)
    	at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)
    	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)
    	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:885)
    	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:797)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:860)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:829)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:409)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:238)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:148)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:247)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:331)
    	at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:155)
    	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:240)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:178)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3692)
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4127)
    	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
    	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
    	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
    	at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:804)
    	at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:693)
    	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472)
    	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1118)
    	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
    	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
    	at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
    	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
    	at org.apache.catalina.core.StandardService.start(StandardService.java:450)
    	at org.apache.catalina.core.StandardServer.start(StandardServer.java:680)
    	at org.apache.catalina.startup.Catalina.start(Catalina.java:536)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:275)
    	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
    Without the aspects, the application runs fine.
    Since I am applying these aspects to all beans (including beans that are already being proxied), is it possible that I'm proxying proxied objects, which is creating this error?

  9. #9
    Join Date
    Dec 2005
    Posts
    4

    Default Oops . . Clarification

    So,
    I tried running the app with one advice at a time. The stack trace in my previous post is when I only have the ThrowsAdvice advice enabled.
    The following stack trace occurs when I only have the TracingBeforeAdvice enabled (it is similar to the stack trace in a previous posting in this thread).

    Code:
    2006-03-06 14:33:13,328 ERROR org.springframework.web.context.ContextLoader - Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'LiquidationDAO' defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptionsException: PropertyAccessExceptionsException (1 errors); nested PropertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy7] to required type [org.springframework.orm.hibernate3.HibernateTemplate] for property 'hibernateTemplate'; nested exception is java.lang.IllegalArgumentException: No matching editors or conversion strategy found]
    PropertyAccessExceptionsException (1 errors)
    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy7] to required type [org.springframework.orm.hibernate3.HibernateTemplate] for property 'hibernateTemplate'; nested exception is java.lang.IllegalArgumentException: No matching editors or conversion strategy found
    java.lang.IllegalArgumentException: No matching editors or conversion strategy found
    	at org.springframework.beans.PropertyTypeConverter.doTypeConversionIfNecessary(PropertyTypeConverter.java:156)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:723)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:575)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:769)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:796)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:785)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:775)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:575)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:405)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:238)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:148)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:253)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:331)
    	at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:155)
    	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:240)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:178)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3692)
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4127)
    	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
    	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
    	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
    	at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:804)
    	at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:693)
    	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472)
    	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1118)
    	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
    	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
    	at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
    	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
    	at org.apache.catalina.core.StandardService.start(StandardService.java:450)
    	at org.apache.catalina.core.StandardServer.start(StandardServer.java:680)
    	at org.apache.catalina.startup.Catalina.start(Catalina.java:536)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:275)
    	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

  10. #10
    Join Date
    Jan 2006
    Posts
    26

    Default

    Try changing the order of interceptors from

    <list>
    <value>loggingThrowsAdvice</value>
    <value>tracingBeforeAdvice</value>
    <value>tracingAfterAdvice</value>
    </list>


    to ..........

    <list>
    <value>tracingBeforeAdvice</value>
    <value>loggingThrowsAdvice</value>
    <value>tracingAfterAdvice</value>
    </list>

Similar Threads

  1. Global errors
    By montana in forum Web
    Replies: 4
    Last Post: Jan 22nd, 2006, 04:29 AM
  2. Replies: 2
    Last Post: May 15th, 2005, 11:27 PM
  3. Global Tracing using AOP
    By MmarcoM in forum AOP
    Replies: 1
    Last Post: Mar 23rd, 2005, 03:53 PM
  4. Where to place global configuration settings?
    By vmarcinko in forum Container
    Replies: 5
    Last Post: Dec 31st, 2004, 05:11 PM
  5. Replies: 2
    Last Post: Oct 8th, 2004, 04:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •