This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes java.lang.NullPtrEx Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.lang.NullPtrEx" Watch "java.lang.NullPtrEx" New topic
Author

java.lang.NullPtrEx

heidi_psl
Greenhorn

Joined: Jun 22, 2006
Posts: 8
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
heidi_psl
Greenhorn

Joined: Jun 22, 2006
Posts: 8
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

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

Joined: Jan 10, 2002
Posts: 60811
    
  65

"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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.NullPtrEx
 
Similar Threads
java.sql.SQLException: Io exception: Software caused connection abort: recv fail
Exception Handling
Doubt in Files
can i use the resultset simultaneously?
java.sql.SQLException: Io exception: Software caused connection abort: recv fail