Announcement Announcement Module
Collapse
No announcement yet.
error org.springframework.beans.factory.support.Abstract BeanFactory destroySingletons Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • error org.springframework.beans.factory.support.Abstract BeanFactory destroySingletons

    hi All,
    I am new to spring.
    i am trying the logging mechanism using Spring AOP.
    when i applied AOP for the DAOimple layer it does not gave me any problems but when i am trying the same thing one layer before i.e. ther service layer then it is giving me following problem
    Code:
    Sep 12, 2007 1:23:38 PM org.springframework.beans.factory.support.AbstractBeanFactory destroySingletons
    INFO: Destroying singletons in factory {org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [contentService,authenticationDAO,applicationContext,loggingInterceptor,contentDAO]; root of BeanFactory hierarchy}
    2007-09-12 13:23:38,123 ERROR com.toro.service.dctm.content.ContentServiceInit - Caught an exception loading authenticationServiceContext.xml
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contentService' defined in class path resource [contentServiceContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'contentDao' of bean class [org.springframework.aop.framework.ProxyFactoryBean]: Bean property 'contentDao' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
    org.springframework.beans.NotWritablePropertyException: Invalid property 'contentDao' of bean class [org.springframework.aop.framework.ProxyFactoryBean]: Bean property 'contentDao' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:670)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:572)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:737)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:764)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:753)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1057)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:857)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:378)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:313)
    	at com.toro.service.dctm.content.ContentServiceInit.startUp(ContentServiceInit.java:30)

    Also my application context file looks as below..
    Code:
    <beans>
    	<!-- 
    	<bean id="contentService" class="com.toro.service.dctm.content.ContentServiceImpl">
    		<property name="contentDao" ref="contentDAO" />
    		<property name="authenticationDao" ref="authenticationDAO" />
    		<property name="zipFilePath" value="C:\\ContentZip" />
    	</bean>
    	 -->
    	<bean id="contentService" class="org.springframework.aop.framework.ProxyFactoryBean" >
    		<property name="contentDao" ref="contentDAO" />
    		<property name="authenticationDao" ref="authenticationDAO" />
    		<property name="zipFilePath" value="C:\\ContentZip" />
    		<property name="proxyTargetClass" value="true"/>
    		<property name="target">
    			<bean class="com.toro.service.dctm.content.ContentServiceImpl" />
    		</property>
    		<property name="interceptorNames">
    			<list>				
    				<value>loggingInterceptor</value>
    			</list>
    		</property>		
    	</bean>
    	
    	<bean id="authenticationDAO" class="com.toro.service.dctm.authentication.dao.AuthenticationDAOImpl"></bean>
    		<!-- Configure spring to give a hook to axis2 without a ServletContext -->
    	<bean id="applicationContext" class="org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder" ></bean>
    	
    	<bean id="loggingInterceptor"  class="com.toro.service.dctm.util.LoggingInterceptor"/>
    
    	<bean id="contentDAO" class="org.springframework.aop.framework.ProxyFactoryBean" >
    		<property name="proxyTargetClass" value="true"/>
    		<property name="target">
    			<bean class="com.toro.service.dctm.content.dao.ContentDaoImpl" />
    		</property>
    		<property name="interceptorNames">
    			<list>				
    				<value>loggingInterceptor</value>
    			</list>
    		</property>		
    	</bean>
    </beans>
    I am not getting what is the problem Pleas let me know if i am missing somtthing here..

  • #2
    You are injecting the properties into the ProxyFactoryBean which is obviously not capable. You have to inject the properties into the target bean:

    Code:
    <bean id="contentServiceTarget" class="com.toro.service.dctm.content.ContentServiceImpl">
    	<property name="contentDao" ref="contentDAO" />
    	<property name="authenticationDao" ref="authenticationDAO" />
    	<property name="zipFilePath" value="C:\\ContentZip" />
    </bean>
    
    <bean id="contentService" class="org.springframework.aop.framework.ProxyFactoryBean" >
    	<property name="proxyTargetClass" value="true"/>
    	<property name="target" value="contentServiceTarget"/>
    	<property name="interceptorNames">
    		<list>				
    			<value>loggingInterceptor</value>
    		</list>
    	</property>		
    </bean>
    Joerg

    Comment


    • #3
      Thanks Man,

      I think the only thing i need to change in you code is

      Code:
      	<bean id="contentServiceTarget" class="com.toro.service.dctm.content.ContentServiceImpl">
      		<property name="contentDao" ref="contentDAO" />
      		<property name="authenticationDao" ref="authenticationDAO" />
      		<property name="zipFilePath" value="C:\\ContentZip" />
      	</bean>
      
      	<bean id="contentService" class="org.springframework.aop.framework.ProxyFactoryBean" >
      		<property name="proxyTargetClass" value="true"/>
      		<property name="target" ref="contentServiceTarget" />
      		<property name="interceptorNames">
      			<list>				
      				<value>loggingInterceptor</value>
      			</list>
      		</property>		
      	</bean>
      as the value attribute was giving a problem.

      Comment


      • #4
        Originally posted by sushil View Post
        I think the only thing i need to change in you code is ref="contentServiceTarget" as the value attribute was giving a problem.
        Yes, that might be true. The other property (where you can pass the value) is called targetName I think.

        Joerg

        Comment


        • #5
          Hi,
          The abouve thing is already working in my project but in a newly created project same thing is not working.
          the new code is
          Code:
          	<bean id="loggingInterceptor"  class="com.toro.vl.download.util.LoggingInterceptor"/>
          		
          	<bean id="downloadObjectProxy" class="org.springframework.aop.framework.ProxyFactoryBean" >
          		<property name="proxyTargetClass" value="true"/>
          		<property name="target" ref="/downloadObject" />
          		<property name="interceptorNames">
          			<list>				
          				<value>loggingInterceptor</value>
          			</list>
          		</property>		
          	</bean>
          	
          	<bean id="downloadZipProxy" class="org.springframework.aop.framework.ProxyFactoryBean" >
          		<property name="proxyTargetClass" value="true"/>
          		<property name="target" ref="/downloadZip" />
          		<property name="interceptorNames">
          			<list>				
          				<value>loggingInterceptor</value>
          			</list>
          		</property>		
          	</bean>
          	
          	
          	<bean id="downLoadDaoProxy" class="org.springframework.aop.framework.ProxyFactoryBean" >
          		<property name="proxyTargetClass" value="true"/>
          		<property name="target" ref="downLoadDao" />
          		<property name="interceptorNames">
          			<list>				
          				<value>loggingInterceptor</value>
          			</list>
          		</property>		
          	</bean>
          and the logger class is
          Code:
          package com.toro.vl.download.util;
          
          import java.lang.reflect.Method;
          
          import org.apache.commons.logging.Log;
          import org.apache.commons.logging.LogFactory;
          import org.springframework.aop.AfterReturningAdvice;
          import org.springframework.aop.MethodBeforeAdvice;
          import org.springframework.aop.ThrowsAdvice;
          
          public class LoggingInterceptor implements MethodBeforeAdvice, AfterReturningAdvice, ThrowsAdvice{
          	private static Log log = null;
          	public LoggingInterceptor(){
          	}
          	
          	public void before(Method arg0, Object[] arg1, Object arg2) throws Throwable {
          		System.out.println("###########################Logger B4 Method");
          		log = LogFactory.getLog(arg2.getClass());
          		log.debug("Beginning method: "+arg0.getName());
          	}
          	
          	public void afterReturning(Object arg0, Method arg1, Object[] arg2, Object arg3) throws Throwable {		
          		System.out.println("Logger Aft method");
          		log = LogFactory.getLog(arg3.getClass());
          		log.debug("Ending method: "+arg1.getName());	
          	}
          	
          	public void afterThrowing(Method m, Object[] args, Object target, Throwable ex){ 
          		log = LogFactory.getLog(target.getClass());
          		log.debug("Exception in method: "+m.getName()+" Exception is: "+ex.getMessage());	
          	}
          }
          ireally dont know why this logger class is not working..
          Any help will be appreaciated

          Comment

          Working...
          X