Announcement Announcement Module
Collapse
No announcement yet.
classcast on FieldRetrievingFactoryBean trying to inject GenericDao Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • classcast on FieldRetrievingFactoryBean trying to inject GenericDao

    Hi everyone. I've already searched on the forum for a post on this, but with no luck (sadly). So I'll ask you guys how to handle it.
    I have a service bean, that have to be injected with a dao. This is pretty much common task, but I'm trying to inject a proxy dao (derived from Per Mellqvist article Don't repeat the Dao) in my business layer, and it keeps running with the same Exception - java.lang.ClassCastException: org.springframework.beans.factory.config.FieldRetr ievingFactoryBean
    All my dao tests runs pretty much fine, but now I'm trying to run service tests, and is throwing this exception.

    Here's my code:
    serviceContext.xml
    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"
            xmlns:tx="http://www.springframework.org/schema/tx"
            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
            http://www.springframework.org/schema/tx
            http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
    	<aop:config>
    		<aop:advisor id="serviceTx" advice-ref="txAdvice" pointcut="execution(* *..service.*Service.*(..))"/>
    	</aop:config>    
    	<tx:annotation-driven/>
    	<aop:aspectj-autoproxy />
    	<tx:advice id="txAdvice">
    		<tx:attributes>
    			<tx:method name="*"/>
    		</tx:attributes>
    	</tx:advice>
    </beans>
    serviceBeans.xml
    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"
    	xmlns:tx="http://www.springframework.org/schema/tx"
    	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
            http://www.springframework.org/schema/tx
            http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
    	<tx:advice id="UfTxAdvice">
    		<tx:attributes>
    			<tx:method name="persist" rollback-for="ServiceException" />
    			<tx:method name="detach" rollback-for="ServiceException" />
    		</tx:attributes>
    	</tx:advice>
    	<bean id="ufService" class="com.controlfarma.service.impl.UfServiceImpl">
    		<constructor-arg>
    			<idref bean="ufDao"/>
    		</constructor-arg>
    	</bean>
    </beans>
    daoBeans.xml
    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="ufDao" parent="abstractDao">
            	<property name="proxyInterfaces" value="com.controlfarma.dao.UfDao" />
            	<property name="target">
            		<bean parent="abstractDaoTarget">
            			<constructor-arg value="com.controlfarma.model.Uf" />
            		</bean>
            	</property>
            </bean>
    </beans>
    Manageable.java
    Code:
    package net.dev.java.jnovice.service;
    import java.io.Serializable;
    import java.util.List;
    import net.dev.java.jnovice.service.exception.ServiceException;
    public interface Manageable<Entity> extends Serializable {
        void persist(Entity entity) throws ServiceException;
        void detach(Serializable... pks) throws ServiceException;
        List<Entity> filterBy(Entity e);
        Entity retrieve(Serializable pk);
    }
    ServiceImpl.java
    Code:
    package net.dev.java.jnovice.service.impl;
    import java.io.Serializable;
    import java.util.List;
    import net.dev.java.jnovice.dao.Persistable;
    import net.dev.java.jnovice.service.Manageable;
    import net.dev.java.jnovice.service.exception.ServiceException;
    public class ServiceImpl<Entity> implements Manageable<Entity> {
    	private static final long serialVersionUID = -7161460115421961298L;
    	private Persistable<Entity> dao;
    	public ServiceImpl() {
    	}
    	public void detach(Serializable... pks) throws ServiceException {
    	try {
    			for (Serializable pk : pks) {
    				dao.makeTransient(pk);
    			}
    		} catch (Exception e) {
    			throw new ServiceException();
    		}
    	}
    	public void persist(Entity entity) throws ServiceException {
    		try {
    			dao.makePersistent(entity);
    		} catch (Exception e) {
    			throw new ServiceException();
    		}
    	}
    	public Entity retrieve(Serializable pk) {
    		return dao.doRetrieve(pk);
    	}
    	@SuppressWarnings("unchecked")
    	public List<Entity> filterBy(Entity e) {
    		return dao.filterBy(e);
    	}
    	public Persistable<Entity> getDao() {
    		return dao;
    	}
    	public void setDao(Persistable<Entity> dao) {
    		this.dao = dao;
    	}
    }
    UfService.java
    Code:
    package com.controlfarma.service;
    import java.util.List;
    import com.controlfarma.model.Uf;
    import net.dev.java.jnovice.service.Manageable;
    public interface UfService extends Manageable<Uf> {
    	public static final String SPRING_NAME = "ufService";
    	public List<Uf> searchByAll();
    	public List<Uf> searchByNomeLike(String nome);
    	public List<Uf> searchBySiglaExact(String sigla);
    	public List<Uf> searchByNomeLikeAndSiglaExact(String nome, String sigla);
    	public List<Object[]> scalarByAll();
    	public List<Object[]> scalarByNomeLike(String nome);
    	public List<Object[]> scalarBySiglaExact(String sigla);
    	public List<Object[]> scalarByNomeLikeAndSiglaExact(String nome,
    			String sigla);
    	public List<Uf> filterBy(Uf filter);
    }
    UfServiceImpl.java
    Code:
    package com.controlfarma.service.impl;
    import java.util.List;
    import net.dev.java.jnovice.service.impl.ServiceImpl;
    import com.controlfarma.dao.UfDao;
    import com.controlfarma.model.Uf;
    import com.controlfarma.service.UfService;
    @SuppressWarnings("serial")
    public class UfServiceImpl extends ServiceImpl<Uf> implements UfService {
    	public UfServiceImpl(UfDao dao) {
    		this.setDao(dao);
    	}
    	public List<Uf> filterBy(Uf filter) {
    		return getDao().filterBy(filter);
    	}
    	public List<Object[]> scalarByAll() {
    		UfDao dao = (UfDao) getDao();
    		return dao.scalarByAll();
    	}
    	public List<Object[]> scalarByNomeLike(String nome) {
    		UfDao dao = (UfDao) getDao();
    		return dao.scalarByNomeLike(nome);
    	}
    	public List<Object[]> scalarByNomeLikeAndSiglaExact(String nome,
    			String sigla) {
    		UfDao dao = (UfDao) getDao();
    		return dao.scalarByNomeLikeAndSiglaExact(nome, sigla);
    	}
    	public List<Object[]> scalarBySiglaExact(String sigla) {
    		UfDao dao = (UfDao) getDao();
    		return dao.scalarBySiglaExact(sigla);
    	}
    	public List<Uf> searchByAll() {
    		UfDao dao = (UfDao) getDao();
    		return dao.searchByAll();
    	}
    	public List<Uf> searchByNomeLike(String nome) {
    		UfDao dao = (UfDao) getDao();
    		return dao.searchByNomeLike(nome);
    	}
    	public List<Uf> searchByNomeLikeAndSiglaExact(String nome, String sigla) {
    		UfDao dao = (UfDao) getDao();
    		return dao.searchByNomeLikeAndSiglaExact(nome, sigla);
    	}
    	public List<Uf> searchBySiglaExact(String sigla) {
    		UfDao dao = (UfDao) getDao();
    		return dao.searchBySiglaExact(sigla);
    	}
    }
    Thanks in advance and best regards

    Rafael Mauricio Nami

  • #2
    Is it possible to see the stacktrace?
    Last edited by karldmoore; Aug 29th, 2007, 12:23 PM.

    Comment


    • #3
      Sorry, I forgot to post the stacktrace too.
      Here's the stacktrace

      org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.transaction.interceptor.Trans actionAttributeSourceAdvisor': Cannot create inner bean '(inner bean)' of type [org.springframework.transaction.interceptor.Transa ctionInterceptor] while setting bean property 'transactionInterceptor'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '(inner bean)': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'transactionManager' defined in URL [file:/C:/Ji/projetoIconix/clientesBackend/bin/daoContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in URL [file:/C:/Ji/projetoIconix/clientesBackend/bin/daoContext.xml]: Initialization of bean failed; nested exception is java.lang.ClassCastException: org.springframework.beans.factory.config.FieldRetr ievingFactoryBean
      Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '(inner bean)': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'transactionManager' defined in URL [file:/C:/Ji/projetoIconix/clientesBackend/bin/daoContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in URL [file:/C:/Ji/projetoIconix/clientesBackend/bin/daoContext.xml]: Initialization of bean failed; nested exception is java.lang.ClassCastException: org.springframework.beans.factory.config.FieldRetr ievingFactoryBean
      Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'transactionManager' defined in URL [file:/C:/Ji/projetoIconix/clientesBackend/bin/daoContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in URL [file:/C:/Ji/projetoIconix/clientesBackend/bin/daoContext.xml]: Initialization of bean failed; nested exception is java.lang.ClassCastException: org.springframework.beans.factory.config.FieldRetr ievingFactoryBean
      Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in URL [file:/C:/Ji/projetoIconix/clientesBackend/bin/daoContext.xml]: Initialization of bean failed; nested exception is java.lang.ClassCastException: org.springframework.beans.factory.config.FieldRetr ievingFactoryBean
      Caused by: java.lang.ClassCastException: org.springframework.beans.factory.config.FieldRetr ievingFactoryBean
      at net.dev.java.jnovice.hibernate.util.impl.FinderInt roductionInterceptor.invoke(FinderIntroductionInte rceptor.java:81)
      at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :161)
      at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:202)
      at $Proxy8.isSingleton(Unknown Source)
      at org.springframework.beans.factory.support.Abstract BeanFactory.getObjectForBeanInstance(AbstractBeanF actory.java:1187)
      at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:265)
      at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:163)
      at ...

      Thanks in advance and Best regards
      PS - I'm using Spring 2.0.3 with Hibernate 3 and Hibernate annotations

      Comment


      • #4
        The stacktrace names the daoContext.xml as the problem. Is it possible to see that file as well?
        Last edited by karldmoore; Aug 29th, 2007, 12:23 PM.

        Comment


        • #5
          Sorry, here it goes
          daoContext.xml
          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="dataSource"
                      class="org.apache.commons.dbcp.BasicDataSource">
                  <property name="driverClassName" value="org.h2.Driver"/> 
                  <property name="url" value="jdbc:h2:file:C:\projetos\database\ControlFarma.db"/>
                  <property name="username" value="sa"/>
                  <property name="password" value=""/>
                  <property name="maxActive" value="10"/>
                  <property name="maxIdle" value="5"/>
                  <property name="maxWait" value="1000"/>
              </bean>
              <bean id="namingStrategy"
                    class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
                  <property name="staticField" value="org.hibernate.cfg.ImprovedNamingStrategy.INSTANCE"/>
              </bean>
              <bean id="extendedFinderNamingStrategy"
                  class="net.dev.java.jnovice.hibernate.util.impl.ExtendedFinderNamingStrategy" />
              <bean id="sessionFactory"
                      class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
                  <property name="namingStrategy">
                      <ref bean="namingStrategy" />
                  </property>
                  <property name="dataSource" ref="dataSource"/>
                  <property name="configLocation" value="hibernate-cfg.xml"/>            
                  <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration"/>
              </bean>
              <bean id="transactionManager"
                      class="org.springframework.orm.hibernate3.HibernateTransactionManager">
                  <property name="sessionFactory" ref="sessionFactory" />
              </bean>
              <bean id="finderIntroductionAdvisor" class="net.dev.java.jnovice.hibernate.util.impl.FinderIntroductionAdvisor"/>	
          	<bean id="abstractDaoTarget"
                    class="net.dev.java.jnovice.dao.hibernate.HibernateDao" abstract="true">
                      <property name="sessionFactory" ref="sessionFactory"/>
                      <property name="namingStrategy" ref="extendedFinderNamingStrategy" />        
              </bean>
              <bean id="abstractDao"
                    class="org.springframework.aop.framework.ProxyFactoryBean" abstract="true">
                  <property name="interceptorNames">
                      <list>
                          <value>finderIntroductionAdvisor</value>
                      </list>
                  </property>
              </bean>
          </beans>
          The strange thing is that it works for my dao unit tests. Here is the dao proxy interface code:
          Code:
          package net.dev.java.jnovice.dao;
          import java.io.Serializable;
          import java.lang.reflect.Method;
          import java.util.List;
          public interface Persistable<Entity> {
              void doEvict(Entity entity);
              Entity doRetrieve(Serializable pk);
              void makePersistent(Entity entity);
              void makeTransient(Serializable pk);
              void doInitialize(Entity entity);
              List<Entity> executeSearch(Method method, Object[] queryArgs);
              List<Object[]> executeScalar(Method method, Object[] queryArgs);
              List<Entity> executeFilter(Method method, Object[] filterArgs);
              List<Entity> filterBy(Entity e);
          }
          and the dao testcase:
          Code:
          package com.controlfarma.dao;
          import static org.junit.Assert.assertNotNull;
          import static org.junit.Assert.assertTrue;
          import java.util.List;
          import net.dev.java.jnovice.dao.test.hibernate.BaseDaoHibernateTest;
          import org.junit.AfterClass;
          import org.junit.BeforeClass;
          import org.junit.Test;
          import com.controlfarma.model.Uf;
          public class UfDaoTest extends BaseDaoHibernateTest{
          	private Uf uf;
          	private static UfDao dao;
          	private static Long id;
          	@BeforeClass
          	public static void startTest() throws Exception{
          		dao = (UfDao) ctx.getBean(UfDao.SPRING_NAME);
          	}
          	@AfterClass
          	public static void finishTest() throws Exception {
          		dao = null;
          	}
          	@Override
          	public void setUp() throws Exception {
          		uf = new Uf();
          		uf.setNome("test");
          		uf.setSigla("tt");
          		dao.makePersistent(uf);
          		id = uf.getId();
          	}
          	@Override
          	public void tearDown() throws Exception {
          		uf = null;
          		dao.makeTransient(id);
          	}
          	@Test
          	public void searchByAll() throws Exception {
          		List<Uf> result = dao.searchByAll();
          		assertNotNull(result);
          		assertTrue(result.size() > 0);
          	}
          	@Test
          	public void searchByNomeLike() throws Exception {
          		List<Uf> result = dao.searchByNomeLike("t");
          		assertNotNull(result);
          		assertTrue(result.size() > 0);
          	}
          	@Test
          	public void searchBySiglaExact() throws Exception {
          		List<Uf> result = dao.searchBySiglaExact("tt");
          		assertNotNull(result);
          		assertTrue(result.size() > 0);
          	}
          	@Test
          	public void searchByNomeLikeSiglaExact() throws Exception {
          		List<Uf> result = dao.searchByNomeLikeAndSiglaExact("t","tt");
          		assertNotNull(result);
          		assertTrue(result.size() > 0);
          	}
          	@Test
          	public void filterBy() throws Exception {
          		uf = new Uf();
          		uf.setNome("t");
          		uf.setSigla("tt");
          		List<Uf> result = dao.filterBy(uf);
          		assertNotNull(result);
          		assertTrue(result.size() > 0);
          	}
          	@Test
          	public void scalarByAll() throws Exception {
          		List<Object[]> result = dao.scalarByAll();
          		assertNotNull(result);
          		assertTrue(result.size() > 0);
          	}
          	@Test
          	public void scalarByNomeLike() throws Exception {
          		List<Object[]> result = dao.scalarByNomeLike("t");
          		assertNotNull(result);
          		assertTrue(result.size() > 0);
          	}
          	@Test
          	public void scalarBySiglaExact() throws Exception {
          		List<Object[]> result = dao.scalarBySiglaExact("tt");
          		assertNotNull(result);
          		assertTrue(result.size() > 0);
          	}
          	@Test
          	public void scalarByNomeLikeSiglaExact() throws Exception {
          		List<Object[]> result = dao.scalarByNomeLikeAndSiglaExact("t","tt");
          		assertNotNull(result);
          		assertTrue(result.size() > 0);
          	}
          }
          PS - the BaseDaoHibernateTest has simply the ApplicationContext and a method annotated with @BeforeClass that initializes the testcase.

          Thanks in advance

          Rafael Mauricio Nami

          Comment


          • #6
            Ok, that makes a little more sense the problem seems to be with the FinderIntroductionAdvisor class. I would presume it's not checking or filtering out anything other than the type it expects. Is it possible to see the code for FinderIntroductionAdvisor?
            Last edited by karldmoore; Aug 29th, 2007, 12:23 PM.

            Comment


            • #7
              Here's FinderIntroductionAdvisor code
              Code:
              package net.dev.java.jnovice.hibernate.util.impl;
              import org.springframework.aop.support.DefaultIntroductionAdvisor;
              public class FinderIntroductionAdvisor extends DefaultIntroductionAdvisor {
                  public FinderIntroductionAdvisor()
                  {
                      // calls contructor passing the interceptor
                      super(new FinderIntroductionInterceptor());
                  }
                  private static final long serialVersionUID = 3571682438602577298L;
                      
              }
              and FinderIntrodutionInterceptor.java
              Code:
              package net.dev.java.jnovice.hibernate.util.impl;
              import net.dev.java.jnovice.dao.Persistable;
              import org.aopalliance.intercept.MethodInvocation;
              import org.springframework.aop.IntroductionInterceptor;
              /**
               * Interceptor to execute queries based in methods defined in interfaces of<br>
               * dao layer.<br>
               * Class based in Per's Mellqvist article, <a href="http://www-128.ibm.com/developerworks/java/library/j-genericdao.html">Don't Repeat the Dao!</a> .
               *
               * @author Rafael Nami
               * @since 18/12/2006
               */
              public class FinderIntroductionInterceptor implements IntroductionInterceptor {
              
                  /**
                   * Constant responsible for delimiting the search method name.<br>
                   * 
                   * @author Rafael Mauricio Nami
                   * @since 18/12/2006
                   */
                  private static final String SEARCH_METHOD_NAME = "search";
              
                  /**
                   * Constant responsible for delimiting the scalar search method name.<br>
                   * 
                   * @author Rafael Mauricio Nami
                   * @since 18/12/2006
                   */
                  public static final String SCALAR_LIST_METHOD_NAME = "scalar";
                  
                   /** Constant responsible for delimiting the filtering method name.<br>
                   * 
                   * @author Rafael Mauricio Nami
                   * @since 18/12/2006
                   */
                  public static final String FILTER_LIST_METHOD_NAME = "filter";
                  
                  public Object invoke(MethodInvocation methodInvocation) throws Throwable {
                      // local variable declaration
                      Persistable executor = null;
                      String methodName = null;
                      Object[] arguments = null;
                      
                      // defines the query executor
                      executor = (Persistable) methodInvocation.getThis();
                      
                      // retrieves the method name
                      methodName = methodInvocation.getMethod().getName();
                      
                      // retrieves the query execution arguments
                      arguments = methodInvocation.getArguments();
                      // If the method name starts with the search constant, executes the
                      // search method in the Dao.
                      if (methodName.startsWith(SEARCH_METHOD_NAME)) {
                          return executor.executeSearch(methodInvocation.getMethod(),
                                          arguments);
                      // If the method name starts with the scalar constant, executes the
                      // scalar search method in the Dao.
                      } else if(methodName.startsWith(SCALAR_LIST_METHOD_NAME)){
                          return executor.executeScalar(methodInvocation.getMethod(),
                                          arguments);            
                          
                      // If the method name starts with the filter constant, executes the
                      // search filter method in the Dao.
                      }else if(methodName.startsWith(FILTER_LIST_METHOD_NAME)){
                          return executor.executeFilter(methodInvocation.getMethod(),
                                          arguments);
                          
                      // Else, pass the method
                      }else{
                          return methodInvocation.proceed();
                      }
                  }
                  public boolean implementsInterface(Class arg0) {
                      return arg0.isInterface()
                                      && Persistable.class.isAssignableFrom(arg0);
                  }
              }
              PS - I tried to configure the service passing the abstractDaoTarget (IE the genericDaoImplementation) but with no luck:
              I tried to do the following on the serviceBeans.xml:
              Code:
              <bean id="ufService"
              		class="com.controlfarma.service.impl.UfServiceImpl">
              		<constructor-arg>
              			<bean class="net.dev.java.jnovice.dao.hibernate.HibernateDao">
              				<constructor-arg value="com.controlfarma.model.Uf" />
              				<property name="sessionFactory" ref="sessionFactory" />
              			</bean>
              		</constructor-arg>
              	</bean>

              Comment


              • #8
                Thanx Karl for the insights.
                I added an instanceof checking on the beginning of the invoke method of the FinderIntroductionInterceptor, and now it's passing this part . URRAY!!!!!!
                Code:
                // type check to ensure that the executor will be always a
                		// Persistable instance.
                		if (methodInvocation.getThis() instanceof Persistable) {
                			// defines the query executor
                			executor = (Persistable) methodInvocation.getThis();
                			// Else, pass the method
                		} else {
                			return methodInvocation.proceed();
                		}
                But now it's showing another kind of demonic monsters . But hey, at least this time the exception is giving me clues on the configuration, right?
                I'll try to check right now the beanFactory configurations.

                Exception:
                org.springframework.beans.factory.BeanCurrentlyInC reationException: Error creating bean with name 'dataSource': Bean with name 'dataSource' has been injected into other beans [sessionFactory] 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.
                at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:435)
                at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 54)
                at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:144)
                at ...

                Thanks in advance

                Rafael Mauricio Nami

                Comment


                • #9
                  Couldn't find the right configuration to prevent this kind of behavior guys...
                  I tried to use all the combinations of autowire and depends-on, but with no luck. I wonder if I have to configure the ApplicationContext by hand... Or serving with a BeanPostProcessor... Don't know how to figure it out yet.

                  Thanks in advance and Best Regards

                  Rafael Mauricio Nami

                  Comment


                  • #10
                    Is it possible to see the full stacktrace, wrapped in code tags. It seems like it's complaining that something wraps the bean after it's been injected. Are you using autowiring anywhere?
                    Last edited by karldmoore; Aug 29th, 2007, 12:23 PM.

                    Comment


                    • #11
                      implement in FinderIntroductionAdvisor
                      Code:
                       @Override
                      	public boolean matches(Class clazz) {
                      		return IFinderExecutor.class.isAssignableFrom(clazz);
                      	}
                      I had the same problem, the interceptor was around every other bean too. the test in FinderIntroductionInterceptor.invoke() will not solve the problem -> only the class cast exception.

                      Comment

                      Working...
                      X