• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NullPointerException

 
Phillipe Rodrigues
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What can be the exact cause of this below err?

java.lang.NullPointerException
at MVC.Example1.doGet(Example1.java:30)
at MVC.Example1.doPost(Example1.java:56)
 
satishkumar janakiraman
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What can be the exact cause of this below err?

java.lang.NullPointerException
at MVC.Example1.doGet(Example1.java:30)
at MVC.Example1.doPost(Example1.java:56)
--------------------

Thanks,



It would be difficult to answer your question without seeing your code. It seems that the reference variable is not initialized properly, but you have tried to access the methods associated with the reference. For example,


the above code snippet will throw NPE since str is not initialized.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15441
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something in line 30 of Example1.java is null when it isn't supposed to be.

NullPointerExceptions are usually easy to solve - just look carefully at the line where the error occurs to see what could be null there.

Since you didn't post the source code, we can't tell you exactly what's wrong. So if you don't see it yourself, show us the code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic