如何在Meecrowave中启用SSE?

时间:2018-12-02 13:28:42

标签: jax-rs cxf cdi server-sent-events

如何在Meecrowave(1.2.4)中启用SSE?

我为org.apache.cxf:cxf-rt-rs-sse:3.2.7添加了依赖项,但是我在资源方法中得到了NPE:

java.lang.NullPointerException: null
at org.apache.cxf.jaxrs.impl.AsyncResponseImpl.initContinuation(AsyncResponseImpl.java:306) ~[cxf-rt-frontend-jaxrs-3.2.7.jar:3.2.7]
at org.apache.cxf.jaxrs.impl.AsyncResponseImpl.<init>(AsyncResponseImpl.java:68) ~[cxf-rt-frontend-jaxrs-3.2.7.jar:3.2.7]
at org.apache.cxf.jaxrs.sse.SseEventSinkContextProvider.createContext(SseEventSinkContextProvider.java:47) ~[cxf-rt-rs-sse-3.2.7.jar:3.2.7]
at org.apache.cxf.jaxrs.sse.SseEventSinkContextProvider.createContext(SseEventSinkContextProvider.java:35) ~[cxf-rt-rs-sse-3.2.7.jar:3.2.7]
at org.apache.cxf.jaxrs.utils.JAXRSUtils.createContextValue(JAXRSUtils.java:1146) ~[cxf-rt-frontend-jaxrs-3.2.7.jar:3.2.7]
at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:874) ~[cxf-rt-frontend-jaxrs-3.2.7.jar:3.2.7]
at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:808) [cxf-rt-frontend-jaxrs-3.2.7.jar:3.2.7]
at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:214) [cxf-rt-frontend-jaxrs-3.2.7.jar:3.2.7]
at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:78) [cxf-rt-frontend-jaxrs-3.2.7.jar:3.2.7]
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) [cxf-core-3.2.7.jar:3.2.7]
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) [cxf-core-3.2.7.jar:3.2.7]
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267) [cxf-rt-transports-http-3.2.7.jar:3.2.7]
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234) [cxf-rt-transports-http-3.2.7.jar:3.2.7]
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208) [cxf-rt-transports-http-3.2.7.jar:3.2.7]
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160) [cxf-rt-transports-http-3.2.7.jar:3.2.7]
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:216) [cxf-rt-transports-http-3.2.7.jar:3.2.7]
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301) [cxf-rt-transports-http-3.2.7.jar:3.2.7]
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:225) [cxf-rt-transports-http-3.2.7.jar:3.2.7]

我在Meecrowave中发现了有关SSE的旧主题:

http://mail-archives.apache.org/mod_mbox/openwebbeans-user/201802.mbox/%3C147540348.1079544.1517463170730%40mail.yahoo.com%3E

但是它现在似乎不相关,因为CXF 3.2.5中重构了SSE:

http://cxf.apache.org/docs/sse.html

1 个答案:

答案 0 :(得分:1)

我发现有没有asyncSupported = true的ServletFilter。在将Filter上的asyncSupported设置为true后,它就可以工作。