File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Null Pointer Exception" Watch "Null Pointer Exception" New topic

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
author & internet detective

Joined: May 26, 2003
Posts: 33132

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

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, 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.
I agree. Here's the link:
subject: Null Pointer Exception
It's not a secret anymore!