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 Servlets and the fly likes Struts context Datasource Null Pointer Exception 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 » Java » Servlets
Bookmark "Struts context Datasource Null Pointer Exception" Watch "Struts context Datasource Null Pointer Exception" New topic
Author

Struts context Datasource Null Pointer Exception

Kinjan Shah
Greenhorn

Joined: Jul 14, 2008
Posts: 1
Hi,

I have weird problem. I am using Tomcat 6.0, Struts, MySQL

DataSource dataSource =(DataSource)context.getAttribute("objdb");

this throws NullPointer Exception

can someone help

Thanks
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Originally posted by Kinjan Shah:
Hi,

I have weird problem. I am using Tomcat 6.0, Struts, MySQL

DataSource dataSource =(DataSource)context.getAttribute("objdb");

this throws NullPointer Exception

can someone help

Thanks


if this statement throws nullpointerexception, thats mean the object "context" is null, How you instantiate the "context" object ?


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

Hi Kinjan Shah welcome to Javaranch,

if you are getting the NullPointerException, then the above post should guide you.
But to me it seems that you are looking for the servlet context's attribute.
So check if you are accessing the context parameter in the right way.

Hope this helps


SCJP, SCWCD.
|Asking Good Questions|
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts context Datasource Null Pointer Exception
 
Similar Threads
DataSource Problem
Creating datasource in WAS 5
Display struts output to jsp
[Urgent] How to configure Datasource externally
Error when I deploy my Strut application on Tomcat