Announcement Announcement Module
Collapse
No announcement yet.
Roo repository - integration test fails to run Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Roo repository - integration test fails to run

    Hi all,
    I am very impressed with Roo and have read as much as I can but am totally stuck. I created entity Question and hoped to use active record pattern to do all my queries. However I discovered that Roo active record does not support pagination or sorting of query results. So I created a repository QuestionRepository

    @RooJpaRepository(domainType = Question.class)
    public interface QuestionRepository

    When I run my unit test QuestionIntegrationTest, I get error below. It seems that Roo cannot create an instance of my QuestionRepository because some argument in the constructor is NULL.

    Many thanks!
    Dave

    2012-12-27 17:54:11,811 [main] ERROR org.springframework.test.context.TestContextManage r - Caught exception while allowing TestExecutionListener [org.springframework.test.context.web.ServletTestEx ecutionListener@40f23491] to prepare test instance [org.inqle.domain.QuestionIntegrationTest@5d593ce6]
    java.lang.IllegalStateException: Failed to load ApplicationContext
    at org.springframework.test.context.TestContext.getAp plicationContext(TestContext.java:157)
    at org.springframework.test.context.web.ServletTestEx ecutionListener.setUpRequestContextIfNecessary(Ser vletTestExecutionListener.java:103)
    at org.springframework.test.context.web.ServletTestEx ecutionListener.prepareTestInstance(ServletTestExe cutionListener.java:73)
    at org.springframework.test.context.TestContextManage r.prepareTestInstance(TestContextManager.java:313)
    at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.createTest(SpringJUnit4ClassRunner.j ava:211)
    at org.springframework.test.context.junit4.SpringJUni t4ClassRunner$1.runReflectiveCall(SpringJUnit4Clas sRunner.java:288)
    at org.junit.internal.runners.model.ReflectiveCallabl e.run(ReflectiveCallable.java:15)
    at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.methodBlock(SpringJUnit4ClassRunner. java:284)
    at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.runChild(SpringJUnit4ClassRunner.jav a:231)
    at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.runChild(SpringJUnit4ClassRunner.jav a:88)
    at org.junit.runners.ParentRunner$3.run(ParentRunner. java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRu nner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentR unner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRu nner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRu nner.java:222)
    at org.springframework.test.context.junit4.statements .RunBeforeTestClassCallbacks.evaluate(RunBeforeTes tClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements .RunAfterTestClassCallbacks.evaluate(RunAfterTestC lassCallbacks.java:71)
    at org.junit.runners.ParentRunner.run(ParentRunner.ja va:300)
    at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.run(SpringJUnit4ClassRunner.java:174 )
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestR eference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:197)
    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'datumDataOnDemand' defined in file [C:\dev\roo\qs\target\test-classes\org\inqle\domain\DatumDataOnDemand.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [org.inqle.domain.DatumDataOnDemand]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.inqle.domain.DatumDataOnDemand': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Could not autowire field: org.inqle.domain.QuestionDataOnDemand org.inqle.domain.DatumDataOnDemand.questionDataOnD emand; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'questionDataOnDemand' defined in file [C:\dev\roo\qs\target\test-classes\org\inqle\domain\QuestionDataOnDemand.clas s]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [org.inqle.domain.QuestionDataOnDemand]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.inqle.domain.QuestionDataOnDemand': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Could not autowire field: org.inqle.repository.QuestionRepository org.inqle.domain.QuestionDataOnDemand.questionRepo sitory; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'questionRepository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: java.lang.NullPointerException
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.instantiateBean(Abstrac tAutowireCapableBeanFactory.java:1011)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBeanInstance(Abst ractAutowireCapableBeanFactory.java:957)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:490)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:461)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 95)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:223)
    ...

  • #2
    I think I found the problem. It turns out my QuestionRepository class had a @Query method with improperly formatted JPQL. I was unclear on how to do a query on references fields. This chapter was helpful
    http://www.manning.com/rimple/SpringRoo-Sample3.pdf

    In any case, I fixed the @Query query, and the errors went away. I note that when the QuestionRepository class has any one of several unrelated errors, I get a similar (unhelpful) error message.

    Comment

    Working...
    X