Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to retrace an unknown NullPointerException

 
Aj Atienza
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Aj Atienza
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use:


And you will have a full stack trace (with line numbers) printed to you logs.
 
Kenneth Brooks
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

@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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks so much for your replies.

I'll try what you guys suggested.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic