Announcement Announcement Module
Collapse
No announcement yet.
interceptor-BeanNameAutoProxyCreator-error Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • interceptor-BeanNameAutoProxyCreator-error

    hi,

    i am trying a simple logging interceptor...below is my spring config...when i get the context and try to get my bean, i get
    Code:
    java.lang.ClassCastException: $Proxy63
    ..
    when i System .out appContext.getBean("userprefDAO"), i get com.hdi.wp.dp.services.common.access.UserPreferenc esDAO@72bd4b0e class and when i System.out appContext.getBean("userprefDAO").getClass(), i get $Proxy63..


    1) xml config
    Code:
    <bean id="loggingInterceptor" class="com.hdi.wp.dp.services.common.cmd.LoggingInterceptor"/>
    	<bean id="userprefDAO" class="com.hdi.wp.dp.services.common.access.UserPreferencesDAO">
    		<property name="sessionFactory"><ref local="appSessionFactory"/></property>
    	</bean>
    
    <bean id="loggingProxy"
         class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
         <property name="beanNames">
           <list>
             <value>*DAO</value>
           </list>
         </property>
         <property name="interceptorNames">
           <list>
             <value>loggingInterceptor</value>
           </list>
         </property>
      </bean>

    i have a flow where call goes from service <=> command <=> dao...for testing purpose i am doing the below in command and trying to get dao instance

    Code:
    Class myCommand {
    static {
    		try {
    			System.out.println("<<<<<<<<<<< Loading Spring Properties>>>>>>>>>>>>>>>>>>");
    			appContext = new ClassPathXmlApplicationContext(new String[] {"spring-config.xml" });
    			System.out.println("<<<<<<<<<<< Loaded >>>>>>>>>>>>>>>>>>");
    		}
    		catch (Exception e){
    			System.out.println ("Exception in finding bean " + e);
    			e.printStackTrace();
    		}
    		
    	}
    public myfunction () {
    com.hdi.wp.dp.services.common.access.UserPreferencesDAO dao = (com.hdi.wp.dp.services.common.access.UserPreferencesDAO) appContext.getBean("userprefDAO");
    //getting class cast exception here..
    }
    }
    i see interceptor getting invoked when i try to print the class name...if i remove the beanautoproxy, everything works fine...
    Last edited by aravindbv; Aug 25th, 2006, 09:30 AM.

  • #2
    myDAO extends org.springframework.orm.hibernate.support.Hibernat eDaoSupport..

    if i remove extends then everything is working fine.do i need to use org.springframework.orm.hibernate3.support.Hiberna teDaoSupport for getting this bean from conext?...i tried to get bean by class also and following exception is thrown

    Code:
    org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'userprefDAO' must be of type [com.hdi.wp.dp.services.common.access.UserPreferencesDAO], but was actually of type [$Proxy66]
    Last edited by aravindbv; Aug 25th, 2006, 09:29 AM.

    Comment


    • #3
      The class cast should work. What version of Spring and cglib are you using?

      P.S. your posts will be more readable if you use the [C.O.D.E]...[/C.O.D.E] tags to enclose verbatim text like code and stack traces.

      Comment


      • #4
        using spring 1.2.8 and cglib-nodep-2.1

        Comment


        • #5
          Again, similar to the solution for your other post, you can try setting the proxyTargetClass property to true for the BeanNameAutoProxyCreator definition.

          Comment

          Working...
          X