users@jersey.java.net

Re: [Jersey] Unable to create responses with Response.build()

From: Trygve Laugstøl <trygvis_at_inamo.no>
Date: Mon, 09 Mar 2009 22:44:58 +0100

Doh, that explains it. Thanks!

--
Trygve
Marc Hadley wrote:
> The stacktrace looks odd, its trying to use the Restlet JAX-RS runtime 
> from within Jersey. I think you must have the Restlet jax-rs impl jar 
> somewhere on your classpath and this may be the cause of the problem.
> 
> Marc.
> 
> On Mar 8, 2009, at 6:59 PM, Trygve Laugstøl wrote:
> 
>> Hi!
>>
>> I'm running into an issue with Jersey while trying to use the Response 
>> class to build a proper response to the client. This is the entire 
>> method in my resource:
>>
>> @POST
>> @Path("sessions")
>> public Response addSession(@PathParam("eventId") String id, SessionV1 
>> entity) {
>>    Session input = ExternalV1F.session.f(entity);
>>    emsServer.saveSession(id, input);
>>
>>    URI location = URI.create(input.getId());
>>
>>    return Response.created(location).build();
>> }
>>
>> The Resource class is annotated with @Path("/1/events/{eventId}"), 
>> @Produces("application/xml") and @Consumes("application/xml"). The 
>> resources are wired with Spring.
>>
>> The Response is created properly, but when Jersey is trying to return 
>> the code to the client I get this exception:
>>
>> java.lang.IllegalArgumentException: This method supports only the 
>> Types Cookie, CacheControl, EntityTag, NewCookie and MediaType
>>     at 
>> org.restlet.ext.jaxrs.internal.spi.RuntimeDelegateImpl.createHeaderDelegate(RuntimeDelegateImpl.java:98) 
>>
>> location = cb0aa937-ed53-4b7b-935b-d6b516eeac11
>>     at 
>> com.sun.jersey.spi.container.ContainerResponse.getHeaderValue(ContainerResponse.java:185) 
>>
>>     at 
>> com.sun.jersey.spi.container.servlet.ServletContainer$Writer.writeStatusAndHeaders(ServletContainer.java:238) 
>>
>>     at 
>> com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:209) 
>>
>>     at 
>> com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:593) 
>>
>>     at 
>> com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:514) 
>>
>>     at 
>> com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:505) 
>>
>>     at 
>> com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:359) 
>>
>>     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.security.SecurityHandler.handle(SecurityHandler.java:216) 
>>
>>     at 
>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>>     at 
>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
>>     at 
>> org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
>>     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.content(HttpConnection.java:843) 
>>
>>     at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
>>     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.java:228) 
>>
>>     at 
>> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488) 
>>
>>
>> Does anyone know what's going on, am I doing something wrong here?
>>
>> -- 
>> Trygve
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>