wood burning stoves 2.0*
The moose likes Java in General and the fly likes Problem with NullPointerException Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Problem with NullPointerException Error" Watch "Problem with NullPointerException Error" New topic
Author

Problem with NullPointerException Error

Abiodun Adisa
Ranch Hand

Joined: Jan 17, 2002
Posts: 495
Hello,
I am Having a problem with Null Pointer Exception. I have this method which i know can return a Null result

if (message.getJMSCorrelationID().equals(null)){
message.setJMSCorrelationID("1");
}

And i am doing the test and i have taking care of the Null problem by setting the JMSCorrelationID to 1, but its still giving me an error, Jumping to the Catch Block Instead
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3419
    
  12
Originally posted by Abiodun Oyesiji:
Hello,
I am Having a problem with Null Pointer Exception. I have this method which i know can return a Null result

if (message.getJMSCorrelationID().equals(null)){
message.setJMSCorrelationID("1");
}

And i am doing the test and i have taking care of the Null problem by setting the JMSCorrelationID to 1, but its still giving me an error, Jumping to the Catch Block Instead


Try


Joanne
Abiodun Adisa
Ranch Hand

Joined: Jan 17, 2002
Posts: 495
Tried That Still not working
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18508
    
  40

Don't guess on what could be causing the NPE. The stack trace actually does a great job at giving you the file and line number where the exception occured.

You should confirm that it is actually where you think it is first.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Shaan Shar
Ranch Hand

Joined: Dec 27, 2005
Posts: 1249

Originally posted by Joanne Neal:


Alternatively you can try this one



But you must show the stack trace, this can be possible that the original source of nullPointerException can be unawered by you completely.

Pls share the stack trace alongwith the code so that we can identify the nullpointer exception.

Hope this helps you.


The Best way to predict your future is to create it - Every great individual common man
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem with NullPointerException Error
 
Similar Threads
Set Chained OFF error while executing from my Bean
Validations using ActionErros Validate
Injection of EJB in POJO class not working..
Problem with NullPointerException Error
Getting Session as null