aspose file tools*
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 Spring in Action this week in the Spring 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: 3646
    
  15
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: 18896
    
  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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with NullPointerException Error