Announcement Announcement Module
Collapse
No announcement yet.
PerformanceMonitorInterceptor and Circular Reference with JPA Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • PerformanceMonitorInterceptor and Circular Reference with JPA

    I am trying to do a simple thing: use the PerformanceMonitorInterceptor
    on a bean.

    I am getting a puzzling error:

    Code:
    15:00:38,312 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@131f0b3: defining beans [xfire.customEditorConfigurer,xfire.serviceRegistry,xfire.transportManager,xfire,xfire.typeMappingRegistry,xfire.aegisBindingProvider,xfire.serviceFactory,xfire.servletController,xfire.messageServiceFactory,xfire.messageBindingProvider,globalPropertyConfigurer,logDSocketFactory,logDDecoratorWebServiceParent,exampleHandlerParent,exampleAnalogHalfHourlyHandler,exampleSubsHandler,exampleComponentsGivenSubHandler,org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor#0,changesDAO,changesThreadDAO,dataSource,entityManagerFactory,transactionManager,org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#0,org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#1,performanceMonitorInterceptor,performanceProxiedJpaStrategy,logDDecoratorWebService,jpaStrategy,handlerParent,logDAnalogHalfHourlyHandler,logDSubsHandler,logDComponentsGivenSubHandler,webAnnotations,xfireHandlerMapping,urlMapping]; root of factory hierarchy
    15:00:38,312 INFO  [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean] Closing JPA EntityManagerFactory for persistence unit 'ULS'
    15:00:38,328 ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
    org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'changesDAO': Bean with name 'changesDAO' has been injected into other beans [jpaStrategy] 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.
    Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'performanceProxiedJpaStrategy' defined in ServletContext resource [/WEB-INF/applicationContext-prod.xml]: Cannot resolve reference to bean 'jpaStrategy' while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaStrategy' defined in ServletContext resource [/WEB-INF/applicationContext-prod.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
    PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'test' threw exception; nested exception is java.lang.NullPointerException
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:514)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:246)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:166)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:243)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:167)
    Note that the error message is complaining about one of my JPA
    DAOs...something that I am not even TRYING to proxy. Of course, the DAO
    IS being proxied, but I can't understand how the various proxies are
    interfering; the JPA proxy is being injected into the TARGET class that
    I am trying to profile/proxy.

    The other interesting thing is that the code that barfs has ALREADY
    successfully executed another DAO (changesThreadDAO)...

    I'd be grateful for any suggestions/advice on this matter. I THOUGHT it
    would be simple ;-)

    Cheers,

    Alph

    ===

    Some relevant configuration:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
    
      <bean id="performanceMonitorInterceptor"
        class="org.springframework.aop.interceptor.PerformanceMonitorInterceptor">
        <property name="loggerName" value="PerformanceInterceptor" />
      </bean>
    
      <bean id="performanceProxiedJpaStrategy" 
        class="org.springframework.aop.framework.ProxyFactoryBean">
        <!-- property name="proxyTargetClass" value="true" / -->
        <property name="proxyInterfaces">
           <value>handler.i.Strategy</value>
        </property>
        <property name="target">
          <ref local="jpaStrategy"/>
        </property>
        <property name="interceptorNames">
          <list>
            <value>performanceMonitorInterceptor</value>
          </list>
        </property>
      </bean>
    
      <bean id="jpaStrategy"
        class="handler.i.strategy.JPAStrategy">
        <property name="changesDAO">
          <ref bean="changesDAO" />
        </property>
        <property name="changesThreadDAO">
          <ref bean="changesThreadDAO" />
        </property>
        ... elided ...
      </bean>
    
      <bean id="handlerParent" abstract="true">
        <property name="IStrategy">
          <ref local="performanceProxiedJpaStrategy" />
        </property>
      </bean>
    
     ... elided ...
    
      <bean id="Handler" parent="handlerParent"
        class="handler.impl.HandlerImpl" />
    
     ... elided ...
    
      <bean id="changesDAO"
        class="handler.i.strategy.jpa.JpaChanges" />
    
      <bean id="changesThreadDAO"
        class="handler.i.strategy.jpa.JpaChangesThread" />
    
    </beans>
Working...
X