• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jdbctemplate not getting created in the DAO class

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting null pointer for the jdbcTemplate even when i have auto wired it .Please suggest what could be wrong.
THe same validationDAO works from a struts action clas and query get executed as well.But it does not work from the utility class.
I tried moving it to the service package and also created Service annotation.
Please help find the errror.



THe following is the code of DAO






XML config




Thanks
Hiren
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You component scan base package of

base-package="com.k1.k2"

doesn't match the packages of your classes your posted.

On another not. k1, k2, d1, d2 are terrible package names, they tell us nothing. What the heck does it even mean. I don't want to know what it means but package structure and naming are just as important as class and interface naming.

Mark
 
Shah Hiren
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have corrected the package names.












The service xlsxtocsv.class calls ValidationDAO .But ValidationDAO is not getting injected with jdbc template.
 
Shah Hiren
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
web.xml










 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And where is your <bean id="jdbcTemplate" …..

in your config file(s)

I expect that you would have one because @Autowired is required by default. So you would get an exception at ApplicationContext startup if there wasn't a jdbcTemplate defined somewhere.

Also, for your component-scan

><context:component-scan base-package="com.ericson.sales"/>


That is all you need. The include you have is redundant, unless there is other classes in your com.ericson.sale package that you do not want to be a Spring Bean and is annotated with @Component or any of the stereotype annotations like @Service.

Mark
 
reply
    Bookmark Topic Watch Topic
  • New Topic