aspose file tools*
The moose likes Servlets and the fly likes how to retrace an unknown NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to retrace an unknown NullPointerException" Watch "how to retrace an unknown NullPointerException" New topic
Author

how to retrace an unknown NullPointerException

Aj Atienza
Greenhorn

Joined: Feb 20, 2005
Posts: 11
Hello java gurus! (my first post at javaranch! woohoo!)

How can I retrace an unknown NullPointerException which keeps on popping out in the error logs of the webserver?

The webserver is Sun ONE Web Server 6.1 and the error logs displays the following:



It has no stack, so I am having a hard time searching for the source of the Exception. The web application is working perfectly but with that Exception popping out at almost every 10 seconds, I'm getting worried that it is a minor error that might lead to a big one.

Thanks!
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489

I would suggest that u temporarily direct ur server o/p to the console and then use an ide like eclipse, establish breakpoints and debug the problem.

tx,
ram.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

ramprasad madathil,
thank you for the reply, but please oh please reduce the use of abbreviations in your posts.

SMS and IRC short cuts like u, ur, o/p, tx may be useful when typing in real time, but they only serve to make your posts harder understand here. We request that people don't use them.

thanks,
Dave.
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489


ramprasad madathil,
thank you for the reply, but please oh please reduce the use of abbreviations in your posts.

SMS and IRC short cuts like u, ur, o/p, tx may be useful when typing in real time, but they only serve to make your posts harder understand here. We request that people don't use them.


Point taken, i apologize

ram.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

AJ,
I would suggest wrapping parts of your code in try/catch blocks to debug.
In the catch block, call exception.printStackTrace(). It will dump a fairly verbose stacktrace to your logs.

Better yet, implement log4j so you can tune your logging level without having to alter you code.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Aj Atienza
Greenhorn

Joined: Feb 20, 2005
Posts: 11
Thanks for the replies guys!

@ramprasad: Will it be possible to debug the web server without modifying it's configuration?

@Ben: I already wrapped my code in try/catch blocks, but still, a NullPointerException passes thru.

How is it possible that a NullPointerException is printed out but without a stack trace?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Use:


And you will have a full stack trace (with line numbers) printed to you logs.
Kenneth Brooks
Greenhorn

Joined: Feb 21, 2005
Posts: 9
AJ

How is it possible that a NullPointerException is printed out but without a stack trace?


Sounds to me like you have a case where a developer has done something like the following:



See if that might be the case. If its happening every 10 seconds or so, I would think that its obviously a common thing they are hitting. Perhaps something like a user login.

In anycase I would still try to hook a debugger up to it.
You shouldn't really have to make any changes to the server, just enable jdpa on a port, and point your IDE to it.
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489


@ramprasad: Will it be possible to debug the web server without modifying it's configuration?


Yes, Kenneth in the post above, has shown the way. Enable jpda and specify a port (how you exactly achieve this depends on the server your application is running on. If its Tomcat and you are using eclipse, an execellent link)here's

Most ides do support remote debugging, so if you are not using eclipse, look around for some docs which would help you set it up.

Kenneth has also guessed a probable cause (catch block just logging the erro), which I think, you would do well to check up. But given the fact that the application doesnt crash, probably there should be a good reason why the developer wrote it that way (if he indeed really has)

ram.
Aj Atienza
Greenhorn

Joined: Feb 20, 2005
Posts: 11
Thanks so much for your replies.

I'll try what you guys suggested.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to retrace an unknown NullPointerException