Announcement Announcement Module
Collapse
No announcement yet.
ProxyFactoryBean is not working in Tomcat Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ProxyFactoryBean is not working in Tomcat

    I have defined an object, OrderServiceImpl, that performs the bulk of the work in our system. I wanted to use AOP to time the methods in it. The old tag was <bean id="orderService" class="com.xxx.OrderServiceImpl">. I wrote an implementation of MethodInterceptor that will time the invocation of the underlying method. So, I changed the configuration to match what you see below. I ran my test suite using this configuration and it worked fine and called my timerBean. However, when I deployed this same configuration to Tomcat, I get the stack trace you see at the bottom of this email. I see that it believes there is a circular dependency, but my question is - why isn't there one when I am not timing the methods. The underlying service has the exact same dependencies in both cases. Is there a simple way for me to fix this? Am I missing some very basic? Any assistance is greatly appreciated


    Configuration:
    <bean id="orderServiceImpl" class="com.xxx.OrderServiceImpl" >
    < properties (including references to other beans) >
    </bean>

    <bean id="orderService" class="org.springframework.aop.framework.ProxyFact oryBean" >
    <property name="target" ref="orderServiceImpl" />

    <property name="interceptorNames">
    <list>
    <value>timeMethodBean</value>
    </list>
    </property>
    </bean>



    Stack trace:


    2010-11-30 23:33:06,949 ERROR DispatcherServlet:314 - Context initialization failed
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'timedOrderService' defined in class path resource [ApplicationContext-service.xml]: Cannot resolve reference to bean 'orderServiceImpl' while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'orderServiceImpl' defined in class path resource [ApplicationContext-service.xml]: Cannot resolve reference to bean 'marketCache' while setting bean property 'marketCache'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'marketCache' defined in class path resource [ApplicationContext-service.xml]: Cannot resolve reference to bean 'expirationService' while setting bean property 'expirationService'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'expirationService' defined in class path resource [ApplicationContext-service.xml]: Cannot resolve reference to bean 'timedOrderExpirer' while setting bean property 'timedExpirer'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'timedOrderExpirer' defined in class path resource [ApplicationContext-service.xml]: Cannot resolve reference to bean 'orderService' while setting bean property 'orderService'; nested exception is org.springframework.beans.factory.BeanCurrentlyInC reationException: Error creating bean with name 'timedOrderService': org.springframework.beans.factory.FactoryBeanNotIn itializedException: Cannot determine target class for proxy
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:328)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe finitionValueResolver.java:106)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1317)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:1076)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 91)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:288 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:281 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:574)
    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:425)
    at org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:4 42)
    at org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:4 58)
    at org.springframework.web.servlet.FrameworkServlet.i nitWebApplicationContext(FrameworkServlet.java:339 )
    at org.springframework.web.servlet.FrameworkServlet.i nitServletBean(FrameworkServlet.java:306)
    at org.springframework.web.servlet.HttpServletBean.in it(HttpServletBean.java:127)
    at javax.servlet.GenericServlet.init(GenericServlet.j ava:212)
    at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:1173)
    at org.apache.catalina.core.StandardWrapper.load(Stan dardWrapper.java:993)
    at org.apache.catalina.core.StandardContext.loadOnSta rtup(StandardContext.java:4187)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4496)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:785)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(Sta ndardService.java:519)
    at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalin a.java:581)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:414)

  • #2
    Please use [ code][/code ] tags when posting code!

    Don't use ProxyfactoryBean use aop:config to define your proxies. That is a lot easier, cleaner (no need to change bean id's etc.).

    Comment

    Working...
    X