Questions tagged as 'nullpointerexception'

3
answers

Avoiding comparison "! = null" in Java

I work with Java and for countless times I have to do a test object != null on the object before accessing it to avoid NullPointerException However, I think this practice ends up making the code very ugly, dirty and hard to read....
asked by 06.02.2014 / 11:38
2
answers

Demoiselle JUnit - NullPointerException

When running a unit test with br.gov.frameworkdemoiselle.junit.DemoiselleRunner , the following error is occurring at the end of the test run: java.lang.NullPointerException at br.gov.frameworkdemoiselle.internal.bootstrap.SeBootstr...
asked by 22.02.2015 / 16:18
3
answers

How to catch a NullReferenceException?

When I test my application, it returns some specific data, but when the requested data is null, this unhandled exception error appears ItriedtocapturehimbutIthinkI'mwrong.HowcanIleaveatreatmentthatwarnsinatextboxthattherequesteddatawasnotfou...
asked by 26.11.2015 / 01:24
2
answers

Capturing NullPointerException is bad practice?

I've been messing around with security issues and vulnerabilities lately, and in my research I came across an article that intrigued me. According to OWASP :    Description   It is generally bad practice to catch   NullPointerException....
asked by 16.03.2017 / 13:47
2
answers

NullPointerException Java JPA CDI Tomcat

Good afternoon, guys. I'm developing a Java test application with JPA, CDI and Tomcat. I created a basic test class and I'm getting the following error. Erro: Exception in thread "main" java.lang.NullPointerException at br.com.hcancerbarre...
asked by 29.07.2016 / 21:52
2
answers

The operator! = is undefined for the argument type (s)

I am trying to create a method to save users in the database by doing the following check if the id of the last user is different from null it changes if it does not register. Code public void salvar(Usuario usuario){...
asked by 28.03.2016 / 20:48
1
answer

What causes the 'System.NullReferenceException'?

Sometimes the execution of my systems is interrupted by this error, when it happens, a if(atributo != null) usually resolves, but this pollutes the code, "Ah, but this variable must have a value right?" the problem happens just when I assi...
asked by 30.12.2015 / 13:53
1
answer

Problem with null variable

I'm developing C # software with the MVVM template , and with Visual Studio. It is software to manage the members of a university. We also have to use a database with Code First. My problem is that it gives me the following error:  ...
asked by 09.11.2016 / 16:37
1
answer

NullPointerException error in java

I have a class of type User that has as attribute a vector of Sensors , and class Sensors has as attribute a vector of Data . After creating five User objects and saving them to a txt file, I populated 3 Sensor objects...
asked by 21.07.2015 / 01:02
3
answers

What kind of return from a select count (*) in Spring JPA?

I need to know the type of return that Spring JPA returns to put in the Service package, because it is giving NullPointerException : Dao: public interface PlaylistDao extends JpaRepository<Playlist, Long> { @Query("select co...
asked by 23.11.2018 / 18:47