File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Testing and the fly likes Null Pointer Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Null Pointer Exception" Watch "Null Pointer Exception" New topic
Author

Null Pointer Exception

Schandha Ravi
Ranch Hand

Joined: Oct 20, 2007
Posts: 167
Hi All,

I'm working with HtmlUnit to test a sample web application. But I'm getting a NullPointerException. I'm not able to figure out where and why the exception is generated.



I'm not getting the code displayed under if condition. Can some one guide me here.


Thanks & Regards, SK
SCJP 5.0, DB2 - 800, DB2 - 803, SCDJWS (On the way)
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30116
    
150

Schandha,
What line is generating the null pointer? (You can look at the junit report for a stack trace)


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Schandha Ravi
Ranch Hand

Joined: Oct 20, 2007
Posts: 167
Hi Jeanne,

From the stack trace, the exception is generated at




Not sure why there is an abend. Infact requestSettings is properly intantiated and it has some values. Something went wrong in loadWenResponse

Also I ran the testcase in debug mode, but at the line 34

One more observation is, I'm always getting this exception when ever I call any method on WebClient object. Is the way I initialized WebClient, wrong.

Schandha Ravi
Ranch Hand

Joined: Oct 20, 2007
Posts: 167
That was my bad.

I found the mistake. Apparently WebClient object is null. I have the local object created in setUp() which is apparently not available in testcase.

Its fine now.
 
jQuery in Action, 2nd edition
 
subject: Null Pointer Exception
 
Similar Threads
Regarding sorting data in arraylist
Login to a web forum
upper bound wildcard is readonly but lower bound are not
My Preparation snippets (Collections!)
Login and Download file over https