Announcement Announcement Module
Collapse
No announcement yet.
nested exception is java.lang.NoSuchMethodError: org.springframework.data.repository. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • nested exception is java.lang.NoSuchMethodError: org.springframework.data.repository.

    Code:
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao': FactoryBean threw exception on object creation; nested exception is java.lang.NoSuchMethodError: org.springframework.data.repository.core.RepositoryMetadata.getDomainType()Ljava/lang/Class;
    	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
    	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1442)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:305)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:284)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
    	... 62 more
    Caused by: java.lang.NoSuchMethodError: org.springframework.data.repository.core.RepositoryMetadata.getDomainType()Ljava/lang/Class;
    	at com.sanshen.framework.dao.BaseRepositoryFactoryBean$BaseRepositoryFactory.getTargetRepository(BaseRepositoryFactoryBean.java:34)
    	at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:146)
    	at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:120)
    	at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:39)
    	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
    	... 69 more
    i got this error ,could anybody can help me?
    when I used spring data jpa 1.2.0 ,it happened. this is my code
    Code:
    public class BaseRepositoryFactoryBean<R extends JpaRepository<T, I>, T, I extends Serializable>
    extends JpaRepositoryFactoryBean<R, T, I> {
    	
    	protected RepositoryFactorySupport createRepositoryFactory(EntityManager entityManager) {
    	
    		return new BaseRepositoryFactory(entityManager);
    	}
    	
    	private static class BaseRepositoryFactory<T, I extends Serializable> extends JpaRepositoryFactory {
    	
    		private EntityManager entityManager;
    		
    		public BaseRepositoryFactory(EntityManager entityManager) {
    			super(entityManager);
    			
    			this.entityManager = entityManager;
    		}
    		
    		@SuppressWarnings("unchecked")
    		protected Object getTargetRepository(RepositoryMetadata metadata) {
    		
    			return new BaseRepositoryImpl<T, I>((Class<T>) metadata.getDomainType(), entityManager);
    		}
    		
    		protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) {
    		
    			// The RepositoryMetadata can be safely ignored, it is used by the JpaRepositoryFactory
    			//to check for QueryDslJpaRepository's which is out of scope.
    			return BaseRepository.class;
    		}
    	}
    }

    it is not happened in version 1.1.0
    i used this code:
    Code:
    import java.io.Serializable;
    
    import javax.persistence.EntityManager;
    
    import org.springframework.data.jpa.repository.JpaRepository;
    import org.springframework.data.jpa.repository.support.JpaRepositoryFactory;
    import org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean;
    import org.springframework.data.repository.core.RepositoryMetadata;
    import org.springframework.data.repository.core.support.RepositoryFactorySupport;
    
    public class BaseRepositoryFactoryBean<R extends JpaRepository<T, I>, T, I extends Serializable>
    extends JpaRepositoryFactoryBean<R, T, I> {
    	
    	protected RepositoryFactorySupport createRepositoryFactory(EntityManager entityManager) {
    	
    		return new BaseRepositoryFactory(entityManager);
    	}
    	
    	private static class BaseRepositoryFactory<T, I extends Serializable> extends JpaRepositoryFactory {
    	
    		private EntityManager entityManager;
    		
    		public BaseRepositoryFactory(EntityManager entityManager) {
    			super(entityManager);
    			
    			this.entityManager = entityManager;
    		}
    		
    		@SuppressWarnings("unchecked")
    		protected Object getTargetRepository(RepositoryMetadata metadata) {
    		
    			return new BaseRepositoryImpl<T, I>((Class<T>) metadata.getDomainClass(), entityManager);
    		}
    		
    		protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) {
    		
    			// The RepositoryMetadata can be safely ignored, it is used by the JpaRepositoryFactory
    			//to check for QueryDslJpaRepository's which is out of scope.
    			return BaseRepository.class;
    		}
    	}
    }
    just these expressions are diffrent
    Code:
    return new BaseRepositoryImpl<T, I>((Class<T>) metadata.getDomainType(), entityManager);
    Code:
    return new BaseRepositoryImpl<T, I>((Class<T>) metadata.getDomainClass(), entityManager);
    what is the reason? thanks
    Last edited by meiweirenjian; Jan 7th, 2013, 03:38 AM. Reason: some error

  • #2
    java.lang.NoSuchMethodError: core.RepositoryMetadata.getDomainType()Ljava/lang/Class

    nested exception is java.lang.NoSuchMethodError: org.springframework.data.repository.core.Repositor yMetadata.getDomainType()Ljava/lang/Class;

    Comment


    • #3
      My guess is that you are mixing incompatible versions of spring-data-jpa and spring-data itself... Don't do that... Make sure you are using compatible versions.

      Comment


      • #4
        I fixed this problem, I had used the wrong version of spring-data.thank you

        Comment


        • #5
          Haha. It's the problem of the version of spring-data!!!!!!!!!!!!!!!!!!!

          Comment

          Working...
          X