I am getting simple Null pointer exception which I am unable to resolve. Have tried debugging the application but it just wont go in the dao class where i want it to go. It shows : Unable to Install breakpoint and Absent Line control message. But as i learned from other questions on stack overflow this message was to be ignored ,so that I did.
Details for issue:
Exception :
in test controller
in create Service
at com.service.DesignerService.create(DesignerService.java:20) at com.controller.HomeController.test(HomeController.java:26) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)in create service java.lang.NullPointerException
My controller method :
@GetMapping("/test")
public String test() {
System.out.println( "in test controller");
DesignerService obj = new DesignerService();
try {
obj.create();
} catch (Exception e) {
e.printStackTrace();
}
return "index";
}
My service calling :
public void create (){
System.out.println("in create service");
Designer designer = getDesigner();
designerDao.createDesigner(designer);
}
And Dao where the debugger never reaches
public void createDesigner(Designer designer) {
Session session = null;
try {
session = sessionFactory.openSession();
session.beginTransaction();
String id = String.valueOf(session.save(designer));
System.out.println("Designer ID :"+id);
session.getTransaction().commit();
}catch(Exception e) {
e.printStackTrace();
}
}
Please help me run this project . Many thanks in advance