• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NullPointerException

 
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic