• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

getting Servletcontext in a class

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I would like to get an attribute in WebApplicationContext in DWRFacade class. I extented HttpServlet to DWRFacade class. But i'm getting

WARNING: Method execution failed:
java.lang.NullPointerException
at javax.servlet.GenericServlet.getServletContext(GenericServlet.java:159)
at com.scs.rb.web.utils.DWRFacade.getCounties(DWRFacade.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

I'm sure abt the values in the servletCOntext.

Hw i'll get the values from the servletContext..

Thanks in advance
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is your servlet initialised?
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Post your code. So that, we can have idea about the problem.
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"struts lover",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff
 
Elizabath Lima
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I'm pasting my code for the class


[Edit by Dave - code tags added]
[ April 07, 2006: Message edited by: David O'Meara ]
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think Peter may be right, it looks like your servlet has not been initialised. You could try setting it to initialise on startup in your web.xml, that may help things.
 
Elizabath Lima
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,

Thanks for your reply.
I'm developing this appication in Spring and I'm loading all the necessary xmls using ContextLoaderListener. And the DWRFacade class's bean is defined in one of the xml too.

By the time i tried extending the RBDispatcherServlet to the DWRFacade class, but that too doesn't work.

Can you please tell me what is wrong in my deeds?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic