Paul,
This is all really useful and really great information.
Back to state, not just user state but any type of application state you
may wish to store, is there a standard way of storing/managing state in
Jersey/REST? I know one of the key principles of REST is that your
service should be stateless but its a fact of life that sometimes you
have to store state.
I just wondered what your views were, store in a database or an in
memory model or some other cool RESTful approach :)
Jonathan
-----Original Message-----
From: Jonathan Cook - Online
Sent: 08 April 2008 13:06
To: 'Paul.Sandoz_at_Sun.COM'
Cc: users_at_jersey.dev.java.net
Subject: RE: HttpSession
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.getAnnotation
> Class(ServletContainer.java:276) at
> com.sun.ws.rest.spi.resource.Injectable.inject(Injectable.java:52)
> at
> com.sun.ws.rest.impl.application.WebApplicationImpl.injectResources(We
> bApplicationImpl.java:197)
> at
> com.sun.ws.rest.impl.application.WebApplicationImpl.injectResources(We
> bApplicationImpl.java:189)
> at
> com.sun.ws.rest.impl.application.WebApplicationContext.injectDependenc
> ies(WebApplicationContext.java:95)
> at
> com.sun.ws.rest.impl.resource.PerRequestProvider.getInstance(PerReques
> tProvider.java:70)
> at
> com.sun.ws.rest.impl.application.WebApplicationContext.getResource(Web
> ApplicationContext.java:127)
> at
> com.sun.ws.rest.impl.uri.rules.ResourceClassRule.accept(ResourceClassR
> ule.java:49)
> at
> com.sun.ws.rest.impl.uri.rules.RightHandPathRule.accept(RightHandPathR
> ule.java:83)
> at
> com.sun.ws.rest.impl.uri.rules.RootResourceClassesRule.accept(RootReso
> urceClassesRule.java:49)
> at
> com.sun.ws.rest.impl.application.WebApplicationImpl.handleRequest(WebA
> pplicationImpl.java:246)
> at
> com.sun.ws.rest.spi.container.servlet.ServletContainer.service(Servlet
> Container.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:36
> 2) at
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:18
> 1) at
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:72
> 6) at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:15
> 2) 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(HttpCon
> nection.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.j
> ava:228)
> at
> org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.
> java: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.