Announcement Announcement Module
Collapse
No announcement yet.
nullpointer in data.repository.support when injecting entityManager to JpaRepository Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • nullpointer in data.repository.support when injecting entityManager to JpaRepository

    Hi, (first I have to thank your response first, I'm afraid you won't stay after all the exception print outs) -

    I am attempting to inject an EntityManager into the JpaRepositoryFactoryBean, and got this following exception. Here is my spring config:

    <bean id="repositoryFactoryONE" class="org.springframework.data.jpa.repository.sup port.JpaRepositoryFactoryBean">
    <property name="entityManager" ref="entityManagerFactoryONE"/>
    </bean>

    <jpa:repositories base-package="com.mycom.dao">
    </jpa:repositories>

    the null pointer exception:
    Caused by: java.lang.NullPointerException
    at org.springframework.data.repository.support.Reposi toryInterfaceAwareBeanPostProcessor.getClassForPro pertyValue(RepositoryInterfaceAwareBeanPostProcess or.java:96)
    at org.springframework.data.repository.support.Reposi toryInterfaceAwareBeanPostProcessor.predictBeanTyp e(RepositoryInterfaceAwareBeanPostProcessor.java:8 2)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.predictBeanType(Abstrac tAutowireCapableBeanFactory.java:584)
    at org.springframework.beans.factory.support.Abstract BeanFactory.isFactoryBean(AbstractBeanFactory.java :1319)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.getBeanNamesForType(DefaultList ableBeanFactory.java:315)
    at org.springframework.context.support.AbstractApplic ationContext.getBeanNamesForType(AbstractApplicati onContext.java:1136)
    at org.springframework.context.support.AbstractApplic ationContext.registerListeners(AbstractApplication Context.java:856)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:422)
    at org.springframework.test.context.support.AbstractG enericContextLoader.loadContext(AbstractGenericCon textLoader.java:84)
    at org.springframework.test.context.support.AbstractG enericContextLoader.loadContext(AbstractGenericCon textLoader.java:1)
    at org.springframework.test.context.TestContext.loadA pplicationContext(TestContext.java:280)
    at org.springframework.test.context.TestContext.getAp plicationContext(TestContext.java:304)
    ... 29 more

    I fixed by using entity_manager_factory_ref, as indicated in the namespace of spring data jpa.
    Last edited by truthseeker; May 9th, 2011, 04:33 PM. Reason: fixed
Working...
X