This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Learn Java with Math: Using Fun Projects and Games and have Ron Dai on-line!
See this thread for details.
Win a copy of Learn Java with Math: Using Fun Projects and Games this week in the Beginning Java 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

jdbctemplate not getting created in the DAO class

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • 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: 17344
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
web.xml










 
Mark Spritzler
ranger
Posts: 17344
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • 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
 
You save more money with a clothesline than dozens of light bulb purchases. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!