From: Lamb, M. <Mic...@di...> - 2009-05-21 20:18:46
|
Excuse my naïveté, but I'm not sure I understand how to do that. So I have an implementation of the Application class: public class MyApplication extends Application { public HashSet<Object> singletons = new HashSet<Object>(); public MyApplication() { singletons.add(new MyResourceClass()); } ... I need to pass the ServletContext instance to my ResourceClass. I tried changing the constructor to: public MyApplication(@Context ServletContext ctx) { singletons.add(new MyResourceClass(ctx)); ... But that results in a java.lang.InstantiationException inside of org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap.contextInitializ ed() What am I doing wrong? On 5/19/09 4:36 PM, "Bill Burke" <bb...@re...> wrote: > You should be able to inject it with @Context (if you're using 1.1-RC2). > > Lamb, Michael wrote: >> I need to access the ServletContext on service startup (rather than >> per-request) to get some parameters of the servlet container. >> >> Is there a way to access the ServletContext instance from the >> Application class? >> >> *Michael Lamb >> **Service Operations Specialist III *- Enterprise Automation >> Phone: (206) 664-4151 >> Cell: (206) 818-6302 >> E-Mail: mic...@di... >> >> >> ------------------------------------------------------------------------ >> >> ----------------------------------------------------------------------------->> - >> Crystal Reports - New Free Runtime and 30 Day Trial >> Check out the new simplified licensing option that enables >> unlimited royalty-free distribution of the report engine >> for externally facing server and web deployment. >> http://p.sf.net/sfu/businessobjects >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Resteasy-developers mailing list >> Res...@li... >> https://lists.sourceforge.net/lists/listinfo/resteasy-developers Michael Lamb Service Operations Specialist III - Enterprise Automation Phone: (206) 664-4151 Cell: (206) 818-6302 E-Mail: mic...@di... |