users@jersey.java.net

RE: HttpSession

From: Jonathan Cook - Online <Jonathan.Cook2_at_bbc.co.uk>
Date: Tue, 8 Apr 2008 13:05:36 +0100

Thanks very much!! This is great.

-----Original Message-----
From: Paul.Sandoz_at_Sun.COM [mailto:Paul.Sandoz_at_Sun.COM]
Sent: 08 April 2008 12:46
To: Jonathan Cook - Online
Cc: users_at_jersey.dev.java.net
Subject: Re: HttpSession

Jonathan Cook - Online wrote:
> Paul,
>
> If I try to inject the servlet request using:
> @HttpContext HttpServletRequest r;
>

I am guessing you are using jersey 0.5 or less... add the jsr250-api.jar

to your classpath and use:

  @Resource HttpServletRequest r;

Otherwise if you switch to 0.6 then HttpContext has been renamed to
Context and you no longer require the jsr250-api.jar in the classpath
and you do:

  @Context HttpServletRequest r;

The reason we switched was because we were using @Resource incorrectly.


Note that the example per session provider i sent out earlier will only
work for 0.6 or greater.

Paul.

> I get the following error:
>
> 2008-04-08 12:18:52.335::WARN: Error for /footballfixtures
> java.lang.NoClassDefFoundError: javax/annotation/Resource
> at
>
com.sun.ws.rest.spi.container.servlet.ServletContainer$1.getAnnotationCl
ass(ServletContainer.java:276)
> at com.sun.ws.rest.spi.resource.Injectable.inject(Injectable.java:52)
> at
>
com.sun.ws.rest.impl.application.WebApplicationImpl.injectResources(WebA
pplicationImpl.java:197)
> at
>
com.sun.ws.rest.impl.application.WebApplicationImpl.injectResources(WebA
pplicationImpl.java:189)
> at
>
com.sun.ws.rest.impl.application.WebApplicationContext.injectDependencie
s(WebApplicationContext.java:95)
> at
>
com.sun.ws.rest.impl.resource.PerRequestProvider.getInstance(PerRequestP
rovider.java:70)
> at
>
com.sun.ws.rest.impl.application.WebApplicationContext.getResource(WebAp
plicationContext.java:127)
> at
>
com.sun.ws.rest.impl.uri.rules.ResourceClassRule.accept(ResourceClassRul
e.java:49)
> at
>
com.sun.ws.rest.impl.uri.rules.RightHandPathRule.accept(RightHandPathRul
e.java:83)
> at
>
com.sun.ws.rest.impl.uri.rules.RootResourceClassesRule.accept(RootResour
ceClassesRule.java:49)
> at
>
com.sun.ws.rest.impl.application.WebApplicationImpl.handleRequest(WebApp
licationImpl.java:246)
> at
>
com.sun.ws.rest.spi.container.servlet.ServletContainer.service(ServletCo
ntainer.java:123)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
> at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
> at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
> at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
> at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
> at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
> at org.mortbay.jetty.Server.handle(Server.java:324)
> at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
> at
>
org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConne
ction.java:828)
> at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
> at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
> at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
> at
>
org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.jav
a:228)
> at
>
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.ja
va:450)
>
> maybe I have some missing jar?
>
> Jonathan
>
> http://www.bbc.co.uk
> This e-mail (and any attachments) is confidential and may contain
> personal views which are not the views of the BBC unless specifically
> stated.
> If you have received it in error, please delete it from your system.
> Do not use, copy or disclose the information in any way nor act in
> reliance on it and notify the sender immediately.
> Please note that the BBC monitors e-mails sent or received.
> Further communication will signify your consent to this.

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109
http://www.bbc.co.uk/
This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.