This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang.NullPtrEx

 
heidi_psl
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

In my application iam getting DBconnection obj from context attribute which iam using in all my servlets & jsp's.
but While closing the application iam getting null pointer exception
code goes like this

finally
{
try
{
cont.removeAttribute("connection");
System.out.println("*Context Deatroyed**");
System.out.println("In Finally-- REMOVED CONTEXT ATTRIBUTE ");
}
catch(Exception ex1)
{
System.out.println("In Catch-- EXCEPTION IN removing CONTEXT ATTRIBUTE "+ex1);
}
}
}//end of file
while closing tomcat iam getting following exception
*Context Deatroyed**
In Finally-- REMOVED CONTEXT ATTRIBUTE
context destroyed
java.lang.NullPointerException
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Heidi,
Welcome to JavaRanch!

Are you sure the null pointer is from the finally block? It looks like the last statements in that block are the printlns which are executed.

Try putting the whole thing in a try/catch block and call e.printStackTrace() to get more details on the exception.
 
heidi_psl
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanx jeanne

see my code goes like this,


still iam getting same o/p



i dint give any println with "context destroyed" line .
My Appli is running fine.
I dont know if this error is from My application/not.

Iam using tomcat 4.1,when evr iam starting it i get this



does it has to do anything with the error ia getting


thank u.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Heidi,
Your code is getting exited fine. It may be an exception in the framework.

The other error looks more fatal. Check your web.xml is properly formed. For more questions on that, I recommend creating a new question in the Servlet forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"heidi psl", you have previously been warned on multiple occasions regarding adjusting your display name to meet JavaRanch standards. This is not optional, and this is your final warning. Adjust your display name to comply with the required standards prior to your next post.

Failure to comply will result in the removal of your account.

bear
JavaRanch Sheriff
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic