• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts context Datasource Null Pointer Exception

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic