This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Thank you for your reply but still i am facing the issue.So for your reference i have attached the stack trace. I just started to learning the spring and stuck in this situation.I have made the web project in eclipse and trying to make the sample application.
Also i have made changes as you suggested..
Gives me error at sessionFactory.getCurrentSession() but dosent give error while setsessionFactory()
Right, there's your problem. You used "new EmpDaoImpl()" so the object you've created is not managed by Spring. You never called setSessionFactory() and so SessionFactory is of course null, hence an NPE when you try to dereference it.
You probably want to be getting an EmpDao managed by the Spring container which means you need to inject it somehow in the controller. For example you could create a field in your controller and then setup a constructor or setter to inject it.
For example this is a very common pattern in the controllers we write:
When the controller is constructed an EmployerService will be injected by Spring. In other words the EmployerService bean will be managed by Spring, so any injection we've setup in EmployerService will be taken care of as well.