Get your CodeRanch badge!*
The moose likes Beginning Java and the fly likes NullPointerException? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "NullPointerException?" Watch "NullPointerException?" New topic


Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061

The above code produces output such as

What could cause a NullPointerException? allowedFile is a File object, and as you can see it is NOT null. Besides, if it was, the AllowedProperty constructor throws a NullPointerException with a custom message:

Any ideas why I get a NPE?

Java API Documentation
The Java Tutorial
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24166

The stack trace says the error occurs in the AllowedProperty constructor at line 53. Show us that whole constructor and point out which is line 53 (the first line in a file is line 1) and I will tell you exactly what the problem is.

[Jess in Action][AskingGoodQuestions]
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Thanks. I figured it out. I'm using Netbeans and it took me to the line in the setUp() method when I double clicked on the JUnit output. No wonder I was confused by that.

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: NullPointerException?
Similar Threads
File I/O
problem, please help
InputStream null when recursively transferring files. Jakarta FTP
Usage of list() with File to search files and directories
Files from a directory is not being recognized