This week's giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of liveProject: Build an ML Recommender System and have Kim Falk on-line!
See this thread for details.
Win a copy of liveProject: Build an ML Recommender System this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Why is autowiring working in JUnit test but not in bean?

 
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm using Spring 3.0.5. I'm running a JUnit test to test db connectivity. I have



and when I run the JUnit test, the "sessionFactory" is configured fine. However, another class that is invoked in the JUnit test has an identical "sessionFactory" reference, which remains null ...



This doesn't happen when I run the real application. Any ideas why one autowiring is working and the other isn't connecting at all? When I run my application outside of the JUnit environment, the autowiring within the "WebLeadsDAOImpl" class gets connected just fine.

Thanks, - Dave
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why in WebLeadsDAOImpl the field SessionFactory is static?
Try to make it an instance-method.
 
reply
    Bookmark Topic Watch Topic
  • New Topic