Spring MVC

I dont know why but my Hibernate Template is Giving Null Pointer Exception .. Can Anyone Help here is the Code https://sourceb.in/Bj2c0HLp45
15 Replies
JavaBot
JavaBot10mo ago
This post has been reserved for your question.
Hey @Danix! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Peter Rader
Peter Rader10mo ago
Please show the stacktrace.
Danix
DanixOP10mo ago
Danix
DanixOP10mo ago
here it is @Peter Rader
Peter Rader
Peter Rader10mo ago
This does not look like a NullPointerException
Danix
DanixOP10mo ago
ohh sorry i changed something and then i got this
Peter Rader
Peter Rader10mo ago
Hm, I think I see whats the problem.... Do you ever heard of dependency-injection?
Danix
DanixOP10mo ago
yeh
Peter Rader
Peter Rader10mo ago
Well DaoEntityImp is a spring bean. And only spring should create an instance of the type. But in the class login you create your own instance.
Danix
DanixOP10mo ago
hm
Peter Rader
Peter Rader10mo ago
Try
@PostMapping("/loginResult")
public String loginResult(@ModelAttribute LoginPojo loginpojo , Model model ) {
Model name = model.addAttribute("name", loginpojo.getUsername());

DaoEntity daoEntity = new DaoEntity();
daoEntity.setName(loginpojo.getUsername());
daoEntity.setEmail(loginpojo.getEmail());
daoEntity.setPassword(loginpojo.getPassword());

//DaoEntityImp daoEntityImp = new DaoEntityImp();
daoEntityImp.saveUser(daoEntity);
return "LoginSuccess";

}
@Autowired
DaoEntityImp daoEntityImp;
@PostMapping("/loginResult")
public String loginResult(@ModelAttribute LoginPojo loginpojo , Model model ) {
Model name = model.addAttribute("name", loginpojo.getUsername());

DaoEntity daoEntity = new DaoEntity();
daoEntity.setName(loginpojo.getUsername());
daoEntity.setEmail(loginpojo.getEmail());
daoEntity.setPassword(loginpojo.getPassword());

//DaoEntityImp daoEntityImp = new DaoEntityImp();
daoEntityImp.saveUser(daoEntity);
return "LoginSuccess";

}
@Autowired
DaoEntityImp daoEntityImp;
Danix
DanixOP10mo ago
1min i got an another error @Peter Rader https://sourceb.in/DBPVbBZftM
Peter Rader
Peter Rader10mo ago
Ok, but this problem seems to be solved. Do you like to create a new question?
Danix
DanixOP10mo ago
here is the error yeh sure
JavaBot
JavaBot10mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?