Results 1 to 3 of 3

Thread: Spring 3.0 + Hibernate JPA Implementation - Autowiring not working

  1. #1
    Join Date
    Mar 2011
    Posts
    6

    Default Spring 3.0 + Hibernate JPA Implementation - Autowiring not working

    I am stuck on this issue. I have a simple DAO test case to test out its features. I am persisting objects using JPA Context injection. Initially, I tried to use @Autowire annotation but then I ended up getting "Cannot autowire field" exception.

    As a work around I tried to reference ApplicationContext manually, but later found my EntityManager remains null. I am stuck on this issue. I am pretty sure it's a very simple fix (perhaps configuration) but not sure what.

    Any recommendations/guidance??

  2. #2
    Join Date
    Mar 2011
    Posts
    6

    Default ApplicationContext different when Web App is run in contrast to a single Test Class

    The DAO works if I run the web application. The issue seems to be occurring only when I run a single test class. So when I run this test class, it can't find the autowired bean. So it seems like the ApplicationContext is built differently when the Web App is actually run. And since I'm not running the whole app but just a single test case, the ApplicationContext doesn't include all the beans.

  3. #3
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,631

    Default

    You leave out the most important bit.... The actual code and configuration...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •