users@jersey.java.net

[Jersey] Rép: Re: Use SseFeature with Spring?

From: Alexis Krier <alexis.krier_at_laposte.net>
Date: Thu, 30 Jan 2014 13:00:03 +0100

Hi yes it does it is 9.1.
I have a working example of ssefeature on it. Without spring of course

Michal Gajdos <michal.gajdos_at_oracle.com> a écrit :

>Hi Alexis,
>
>what version of Jetty are you using? Does it support Servlet 3 (for
>async processing)?
>
>thanks,
>Michal
>
>On 30.01.2014, 11:50 , alexis.krier_at_laposte.net wrote:
>> Hello all,
>>
>> I'm trying to extend the example :
>> https://github.com/jersey/jersey/tree/master/examples/helloworld-spring-webapp
>> with the sseFeature.
>>
>> So MyApplication.java is like this:
>>
>> public class MyApplication extends ResourceConfig {
>> public MyApplication() {
>> register(SseFeature.class);
>> register(RequestContextFilter.class);
>> packages("com.example");
>>
>> my web.xml is unmodified
>>
>> my sse resource is
>>
>> @Component
>> @Path("broadcast")
>> public class MyBroadcasterSSE {
>>
>> @Inject
>> SerialTest serialTest; //a class annoted @Component successfully scanned by spring.
>>
>> @GET
>> @Produces(SseFeature.SERVER_SENT_EVENTS)
>> public EventOutput listenToBroadcast() {
>> final EventOutput eventOutput = new EventOutput();
>> serialTest.broadcaster.add(eventOutput);
>> return eventOutput;
>> }
>>
>> my pom.xml
>>
>>
>> org.springframework
>> spring-web
>> 3.2.6.RELEASE
>>
>>
>> org.glassfish.jersey.ext
>> jersey-spring3
>>
>>
>> org.glassfish.jersey.containers
>> jersey-container-servlet
>>
>>
>> org.glassfish.jersey.media
>> jersey-media-moxy
>>
>>
>> org.glassfish.jersey.media
>> jersey-media-sse
>>
>> ...
>>
>> and my error is as the SseFeature was not registered.
>> janv. 30, 2014 11:08:18 AM org.glassfish.jersey.servlet.internal.ResponseWriter suspend
>> Avertissement: Attempt to put servlet request into asynchronous mode has failed.
>> Please check your servlet configuration - all Servlet instances and Servlet filters
>> involved
>> in the request processing must explicitly declare support for asynchronous request
>> processing.
>> java.lang.IllegalStateException: !asyncSupported
>> at org.eclipse.jetty.server.Request.startAsync(Request.java:2042)
>> at
>> org.glassfish.jersey.servlet.async.AsyncContextDelegateProviderImpl$ExtensionImpl.suspend
>> (AsyncContextDelegateProviderImpl.java:87)
>> at
>> org.glassfish.jersey.servlet.internal.ResponseWriter.suspend(ResponseWriter.java:120)
>>
>> Originally I've wrongly made a JIRA on it but after updating my code, it doesn't work.
>> any idea?
>> https://java.net/jira/browse/JERSEY-2366
>>
>> thank you
>