This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts context Datasource Null Pointer Exception

 
Kinjan Shah
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic