users@jersey.java.net

[Jersey] Re: Use SseFeature with Spring?

From: Alexis Krier <alexis.krier_at_laposte.net>
Date: Fri, 31 Jan 2014 10:49:02 +0100

Finally I've found the problem.

Declaring the Jersey servlet in the web.xml make the sseFeature
disabled:
=================
<servlet>
        <servlet-name>SpringApplication</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>javax.ws.rs.Application</param-name>
            <param-value>org.glassfish.jersey.examples.helloworld.spring.MyApplication</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>SpringApplication</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
=================

so the only lines in my web.xml now is the spring listener:
=================
<listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml</param-value>
    </context-param>
=================

and I annotate the Application class
=================
@ApplicationPath("resources")
public class MyApplication extends ResourceConfig {

    public MyApplication () {
            register(SseFeature.class);
        register(RequestContextFilter.class);
        register(MyBroadcasterSSE.class);
=================

like this the sseFeature keeps registered.
I don't know if it's a bug but web.xml doesn't do what the
annotation does.

thx

Le Thu, 30 Jan 2014 13:47:15 +0100
alexis.krier_at_laposte.net a dit:
> if it can help, here is the all project:
> https://github.com/bodtx/sseJersey
>
> SerialTest is reading a comPort, so you can change it for sending any
> kind of data. I think it is not the problem here.
> I've tried without SSE and it works :\