• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Using lazy-init-ed bean as constructor-arg failing

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all

I am new to Spring and learning the DI. I have three simple classes for an experiment.

Class1:



Class2:



Class3:



Beans.xml:



But as pointed in code, it keeps giving me NPE. Even using @Autowired in Class3 gives error. Please suggest what am I doing wrong?

EDIT:

If I dont set the scope to be prototype, it works fine. Else it doesn't.
But I need the scope to be prototype since I want this bean to have a new instance everytime its launched (I am calling it using a button click. But I did not include that code for sake of simplification).
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!