Problems when registering at the bank

Asked

Viewed 32 times

-2

Friends,

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

I am trying to register an analyst with a user (Sario to access the system for a future access control) and an access profile. I have already done the classes of DAO and Bussines to register in the bank but when trying to register occurs old and boring:

java.lang.Nullpointerexception at br.com.deivsoft.controller.Register Analystservlet.doPost(Register Analystservlet.java:56)

I wonder if someone can take a look, already tried to do in other projects and it occurs the same thing, please help a beginner rs since thank you follow the project on github.

https://github.com/deivsonbf/controle-de-produtividade-jsp-servlet

  • Before this error it prints these values: System.out.println("team: "+name); System.out.println("team: "+team);

  • I used to check if the parameters are coming

1 answer

1


java.lang.Nullpointerexception at br.com.deivsoft.controller.Register Analystservlet.doPost(Register Analystservlet.java:56)

Register analystservlet.java

On line 17 Voce declares but does not initialize the variable.

Throughout the code it is not initialized.

Unlike primitive variables, objects are null.

On line 56 Voce calls the 'save' method of the variable that is null.

To solve your Voce problem you can easily change line 17 to

private AnalistaBusiness analistaBusiness = new AnalistaBusiness();

This is a solution that is not in accordance with good practices, since this will generate an unnecessary use of memory 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 this depends, of course, on the architecture of the project as a whole.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.