From: Bill B. <bb...@re...> - 2009-08-29 12:50:05
|
Probably a bug. I'll look into it. sa...@sl... wrote: > Sorry I missed this part from code: > > * > > import > > * javax.servlet.ServletContext; > > @Context > > *private* ServletContext servletCtx; > > > > *protected* *void* setServletContext(ServletContext servletCtx) { > > *this*.servletCtx = servletCtx; > > } > > *protected* ServletContext getServletContext() { > > *return* servletCtx; > > } > > > > > > > On Fri, Aug 28, 2009 at 5:35 PM, sa...@sl... > <mailto:sa...@sl...> <sa...@sl... > <mailto:sa...@sl...>> wrote: > > Hi, > > I'm having trouble injecting ServletContext in my RESTeasy service > class when I invoke it as asynchronous i.e with an asynch=true > parameter. I've tried this with GET and POST. The call gets to the > service but since ServletContext is needed by my app it just prints > for me the error and errors out. Also, when I invoke the service > without the asynch=true it seems to processes as I expect. > > Here is what I have: > > @GET > > @Path("result/{code}") > > @Produces("application/xml") > > *public* ResultBean getResult(@PathParam("code") ErrorCodeType > errorCode, > > @QueryParam("msg") String errorMsg, > > @QueryParam("incidentId") @DefaultValue("1") Integer incidentId) > > *throws* ModuleException, HandlerException { > > debug( > > "getResult"); > > ResultBean result = > > *new* ResultBean(); > > result.setErrorCode(errorCode); > > result.setErrorMsg(errorMsg); > > debug( > > "checking servlet context"); > > *if* (getServletContext() != *null*) { > > debug( > > "servletcontext.getserverinfo"); > > debug( > > "serverinfo:" + getServletContext().getServerInfo()); > > } > > *else* { > > debug( > > "ServletContext is null"); > > } > > *return* result; > > } > > > web.xml: > > <!-- set this if you map the _Resteasy_ _servlet_ to something other > than --> > > <context-param> > > <param-name>resteasy.servlet.mapping.prefix</param-name> > > <param-value>/_handsetservice_</param-value> > > </context-param> > > <context-param> > > <param-name>resteasy.resources</param-name> > > <param-value>com.cisco.ipics.handsetserviceapi.IncidentResourceManager</param-value> > > > </context-param> > > <!-- enable the Asynchronous Job Service --> > > <context-param> > > <param-name>resteasy.async.job.service.enabled</param-name> > > <param-value>true</param-value> > > </context-param> > > <!-- The next context parameters are all optional. > > Their default values are shown as example _param_-values --> > > <!-- How many jobs results can be held in memory at once? --> > > <context-param> > > <param-name>resteasy.async.job.service.max.job.results</param-name> > > <param-value>100</param-value> > > </context-param> > > <!-- Maximum wait time on a job when a client is querying for it --> > > <context-param> > > <param-name>resteasy.async.job.service.max.wait</param-name> > > <param-value>300000</param-value> > > </context-param> > > <!-- Thread pool size of background threads that run the job --> > > <context-param> > > <param-name>resteasy.async.job.service.thread.pool.size</param-name> > > <param-value>100</param-value> > > </context-param> > > <!-- Set the base path for the Job _uris_ --> > > <context-param> > > <param-name>resteasy.async.job.service.base.path</param-name> > > <param-value>/_handsetservice_/_asynch_/jobs</param-value> > > </context-param> > > > > > > <listener> > > <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class> > > > </listener> > > <servlet> > > <servlet-name>_Resteasy_</servlet-name> > > <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class> > > > </servlet> > > <servlet-mapping> > > <servlet-name>_Resteasy_</servlet-name> > > <url-pattern>/_handsetservice_/*</url-pattern> > > </servlet-mapping> > > > > Please let me know if there is a problem with a config or if this is > a bug in the implementation. > > Regards, > > Samir > > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > > > ------------------------------------------------------------------------ > > _______________________________________________ > Resteasy-developers mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/resteasy-developers -- Bill Burke JBoss, a division of Red Hat http://bill.burkecentral.com |