Problems registering for bank

-1

Friends,

I have a system to control productivity of each analyst, I am a beginner and I'm starting with JSP and SERVLET + JPA and I have the following scenario:

I'm trying to register an analyst with a user (user to access the system for a future access control) and an access profile. I already did the classes DAO and Bussines to register in the bank but when trying to register the old and annoying occurs:

  

java.lang.NullPointerException at   br.deivsoft.controller.CatalogAnalystServlet.doPost (RegisterAnalystServlet.java:56)

I would like to know if anyone can take a look, already tried to do in other projects and the same thing happens, please help a beginner rs from ja thank you follow the project in github.

link

    
asked by anonymous 23.02.2018 / 05:53

1 answer

1
  

java.lang.NullPointerException at br.com.deivsoft.controller.WelcomeAnalystServlet.doPost (RegisterAnalystServlet.java:56)

RegisterAnalystServlet.java

In line 17 you declare but do not initialize the variable.

Throughout the code it is not initialized.

Unlike primitive variables, objects are null.

In line 56 you call the 'save' method of the variable that is null.

To solve your problem you can easily change line 17 to

private AnalistaBusiness analistaBusiness = new AnalistaBusiness();

This is a solution that does not conform to good practice, since this will generate an unnecessary memory usage every time the class is instantiated, the most appropriate would be to use a framework and use annotations to create and manipulate a singleton for your software.

All of this depends, of course, on the architecture of the project as a whole.

    
23.02.2018 / 13:15