大量带有 primefaces 的长轮询请求在 IE9 中推送
Huge amount of long polling requests with primefaces push with IE9
我正在尝试使用 primefaces push 来通知客户端事件。我调整了 Primefaces 通知展示,因此它可以与 spring 依赖注入框架一起使用。
JDK 1.8.0_u91, Tomcat 8.0.33, primefaces 5.3, atmosphere 2.4.2, atmosphere-spring 2.4.0
我的浏览器目标是 Internet Explorer 9。
用例如下:
- JSF 页面有一个
- 在 JSF 页面中,我单击了一个按钮,它触发了支持 bean 中的 send2() 方法
- send2() 发布消息到频道 /notify/BOUVIERM
- 在推送端点 (PushDemoResource) 中调用 onMessage() 方法
- 消息被发送回 JSF 页面,javascript 调用函数 handleMessage() 并在屏幕上显示消息。
此示例似乎适用于 firefox,并且 chrome 使用 websocket 协议。
不幸的是,在 Internet Explorer 9 中它回退到长轮询并发送大量请求。它在服务器端生成大量堆栈跟踪,并且在不到 1 分钟的时间内发送了大约 4000 个请求(发送了 3.5MB,接收了 8.5MB)。
您是否认为我配置有误?
非常感谢。
Maven 配置
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime</artifactId>
<version>2.4.2</version>
</dependency>
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-spring</artifactId>
<version>2.4.0</version>
</dependency>
web.xml
<!-- JSF mapping -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Map these files with JSF -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Push Servlet</servlet-name>
<servlet-class>org.primefaces.push.PushServlet</servlet-class>
<init-param>
<param-name>org.atmosphere.cpr.broadcasterCacheClass</param-name>
<param-value>org.atmosphere.cache.UUIDBroadcasterCache</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Push Servlet</servlet-name>
<url-pattern>/primepush/*</url-pattern>
</servlet-mapping>
JSF 页面
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
>
<f:view contentType="text/html">
<ui:composition template="/xhtml/template/layout.xhtml">
<ui:define name="headTitle">
<h:outputText value="Push POC"/>
</ui:define>
<ui:define name="center">
<h:form>
<p:commandButton actionListener="#{pushDemoController.send2}" value="Message simple : /notify/#{request.userPrincipal.name}"/>
</h:form>
<p:growl widgetVar="growlPush" showDetail="true"/>
<p:socket channel="/notify/#{request.userPrincipal.name}" onMessage="handleMessage" />
<script type="text/javascript">
function handleMessage(message) {
PF('growlPush').show([message]);
}
</script>
</ui:define>
</ui:composition>
</f:view>
</html>
托管 bean
import com.agipi.web.util.FacesUtils;
import org.primefaces.push.EventBus;
import org.primefaces.push.EventBusFactory;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import java.io.Serializable;
/**
* Controller servant d'exemple à l'utilisation du framework Push de primefaces.
* Created by devbouvier on 25/05/2016.
*/
@SuppressWarnings("serial")
@ManagedBean
@ApplicationScoped
public class PushDemoController implements Serializable {
public void send2() {
EventBus eventBus2 = EventBusFactory.getDefault().eventBus();
String channel = "/notify/" + FacesUtils.getPrincipal().getName();
eventBus2.publish(channel, "Message envoyé ");
}
}
推送端点
package com.agipi.g2a.tiana.web.controller.demo;
import com.agipi.web.util.FacesUtils;
import org.primefaces.push.EventBus;
import org.primefaces.push.RemoteEndpoint;
import org.primefaces.push.annotation.*;
import org.primefaces.push.impl.JSONEncoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.faces.application.FacesMessage;
import javax.inject.Inject;
import java.io.Serializable;
@PushEndpoint("/notify/{user}")
@Singleton
public class PushDemoResource implements Serializable {
private static final Logger LOGGER = LoggerFactory.getLogger(PushDemoResource.class);
@Inject
private EventBus eventBus;
@Inject
private RemoteEndpoint endpoint;
@PathParam(value = "user")
private String user;
@OnMessage(encoders = {JSONEncoder.class})
public FacesMessage onMessage(String message) {
LOGGER.info("Message recu : {} pour {}", message, user);
return FacesUtils.getMessage("Notification " + message + " pour " + user, FacesMessage.SEVERITY_INFO);
}
@OnClose
public void onClose(RemoteEndpoint r, EventBus e) {
LOGGER.info("Push Demo onClose : [remoteEndpoint={},eventBus={}]", r, e);
}
@OnOpen
public void onOpen(RemoteEndpoint r, EventBus e) {
LOGGER.info("Push Demo onOpen : [remoteEndpoint={},eventBus={}]", r, e);
}
}
启动时大气记录
18:03:59 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AbstractApplicationContext.java:prepareRefresh:510) Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@e123f5b: startup date [Thu May 26 18:03:59 CEST 2016]; parent: Root WebApplicationContext
18:03:59 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AutowiredAnnotationBeanPostProcessor.java:<init>:153) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
18:03:59 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:autoConfigureService:2828) Atmosphere is using org.atmosphere.cpr.DefaultAnnotationProcessor for processing annotation
18:03:59 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (DefaultAnnotationProcessor.java:configure:151) AnnotationProcessor class org.atmosphere.cpr.DefaultAnnotationProcessor$ServletContainerInitializerAnnotationProcessor being used
18:03:59 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AnnotationHandler.java:handleAnnotation:80) Found Annotation in class org.primefaces.push.impl.PushEndpointInterceptor being scanned: interface org.atmosphere.config.service.AtmosphereInterceptorService
18:03:59 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AnnotationHandler.java:handleAnnotation:80) Found Annotation in class org.primefaces.push.impl.PushEndpointProcessor being scanned: interface org.atmosphere.config.AtmosphereAnnotation
18:03:59 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AnnotationHandler.java:handleAnnotation:80) Found Annotation in class org.primefaces.push.impl.PushEndpointMapper being scanned: interface org.atmosphere.config.service.EndpointMapperService
18:03:59 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AnnotationHandler.java:handleAnnotation:80) Found Annotation in class com.agipi.g2a.tiana.web.controller.demo.PushDemoResource being scanned: interface org.primefaces.push.annotation.PushEndpoint
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (ForkJoinPool.java:<init>:48) Using ForkJoinPool java.util.concurrent.ForkJoinPool. Set the org.atmosphere.cpr.broadcaster.maxAsyncWriteThreads to -1 to fully use its power.
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addAtmosphereHandler:638) Installed AtmosphereHandler org.primefaces.push.impl.PushEndpointHandlerProxy mapped to context-path /notify/{user} and Broadcaster Class org.atmosphere.cpr.DefaultBroadcaster
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addAtmosphereHandler:646) Installed AtmosphereInterceptor [@PushEndpoint Interceptor] mapped to AtmosphereHandler org.primefaces.push.impl.PushEndpointHandlerProxy
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:autoDetectWebSocketHandler:2154) Auto detecting WebSocketHandler in /WEB-INF/classes/
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:initWebSocket:1762) Installed WebSocketProtocol org.atmosphere.websocket.protocol.SimpleHttpProtocol
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (JSR356AsyncSupport.java:<init>:68) JSR 356 Mapping path /primepush
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:configureAtmosphereInterceptor:1226) Installing Default AtmosphereInterceptors
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:newAInterceptor:1245) org.atmosphere.interceptor.CorsInterceptor : CORS Interceptor Support
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:newAInterceptor:1245) org.atmosphere.interceptor.CacheHeadersInterceptor : Default Response's Headers Interceptor
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:newAInterceptor:1245) org.atmosphere.interceptor.PaddingAtmosphereInterceptor : Browser Padding Interceptor Support
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:newAInterceptor:1245) org.atmosphere.interceptor.AndroidAtmosphereInterceptor : Android Interceptor Support
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:newAInterceptor:1245) org.atmosphere.interceptor.HeartbeatInterceptor : Heartbeat Interceptor Support
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:newAInterceptor:1245) org.atmosphere.interceptor.SSEAtmosphereInterceptor : SSE Interceptor Support
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:newAInterceptor:1245) org.atmosphere.interceptor.JSONPAtmosphereInterceptor : JSONP Interceptor Support
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:newAInterceptor:1245) org.atmosphere.interceptor.JavaScriptProtocol : Atmosphere JavaScript Protocol
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:newAInterceptor:1245) org.atmosphere.interceptor.WebSocketMessageSuspendInterceptor : org.atmosphere.interceptor.WebSocketMessageSuspendInterceptor
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:newAInterceptor:1245) org.atmosphere.interceptor.OnDisconnectInterceptor : Browser disconnection detection
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:newAInterceptor:1245) org.atmosphere.interceptor.IdleResourceInterceptor : org.atmosphere.interceptor.IdleResourceInterceptor
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:configureAtmosphereInterceptor:1235) Set org.atmosphere.cpr.AtmosphereInterceptor.disableDefaults to disable them.
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor Atmosphere LifeCycle with priority AFTER_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor Track Message Size Interceptor using | with priority BEFORE_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor @PushEndpoint Interceptor with priority AFTER_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor CORS Interceptor Support with priority FIRST_BEFORE_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor Default Response's Headers Interceptor with priority AFTER_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor Browser Padding Interceptor Support with priority AFTER_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor Android Interceptor Support with priority AFTER_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (HeartbeatInterceptor.java:configure:169) HeartbeatInterceptor configured with padding value 'X', client frequency 60 seconds and server frequency 1 seconds
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor Heartbeat Interceptor Support with priority AFTER_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor SSE Interceptor Support with priority AFTER_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor JSONP Interceptor Support with priority AFTER_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor Atmosphere JavaScript Protocol with priority AFTER_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor org.atmosphere.interceptor.WebSocketMessageSuspendInterceptor with priority AFTER_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor Browser disconnection detection with priority AFTER_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor org.atmosphere.interceptor.IdleResourceInterceptor with priority BEFORE_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1039) Using EndpointMapper class org.primefaces.push.impl.PushEndpointMapper
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1048) Using BroadcasterCache: org.atmosphere.cache.UUIDBroadcasterCache
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1053) Default Broadcaster Class: org.atmosphere.cpr.DefaultBroadcaster
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1054) Broadcaster Shared List Resources: false
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1055) Broadcaster Polling Wait Time 100
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1056) Shared ExecutorService supported: true
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1065) Messaging ExecutorService Pool Size unavailable - Not instance of ThreadPoolExecutor
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1072) Async I/O Thread Pool Size: 200
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1078) Using BroadcasterFactory: org.atmosphere.cpr.DefaultBroadcasterFactory
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1079) Using AtmosphereResurceFactory: org.atmosphere.cpr.DefaultAtmosphereResourceFactory
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1080) Using WebSocketProcessor: org.atmosphere.websocket.DefaultWebSocketProcessor
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1090) Invoke AtmosphereInterceptor on WebSocket message true
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1091) HttpSession supported: false
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1093) Atmosphere is using Spring Web ObjectFactory for dependency injection and object creation
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1094) Atmosphere is using async support: org.atmosphere.container.JSR356AsyncSupport running under container: Apache Tomcat/8.0.33 using javax.servlet/3.0 and jsr356/WebSocket API
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1096) Atmosphere Framework 2.4.2 started.
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1098)
For Atmosphere Framework Commercial Support, visit
http://www.async-io.org/ or send an email to support@async-io.org
[2016-05-26 06:04:00,354] Artifact tiana-webui (2):war exploded: Artifact is deployed successfully
[2016-05-26 06:04:00,355] Artifact tiana-webui (2):war exploded: Deploy took 33 427 milliseconds
18:04:00 | [ INFO] | [Thread-15] (AtmosphereFramework.java:run:1174) Latest version of Atmosphere's JavaScript Client 2.3.1
18:04:00 | [ INFO] | [Thread-15] (AtmosphereFramework.java:run:1182)
Atmosphere Framework Updates:
Major Update available (new features): 2.4.3
服务器堆栈跟踪
17:44:17 | [ WARN] | [http-apr-8081-exec-8] (DefaultBroadcaster.java:addAtmosphereResource:1366) Duplicate resource d9a48c99-dc69-4c38-8a58-b40908fb67fa. Could be caused by a dead connection not detected by your server. Replacing the old one with the fresh one
17:44:17 | [ERROR] | [http-apr-8081-exec-8] (AtmosphereFramework.java:doCometSupport:2307) AtmosphereFramework exception
java.lang.IllegalStateException: A filter or servlet of the current chain does not support asynchronous operations.
at org.apache.catalina.connector.Request.startAsync(Request.java:1621)
at org.apache.catalina.connector.RequestFacade.startAsync(RequestFacade.java:1037)
at javax.servlet.ServletRequestWrapper.startAsync(ServletRequestWrapper.java:398)
at javax.servlet.ServletRequestWrapper.startAsync(ServletRequestWrapper.java:398)
at org.springframework.security.web.context.HttpSessionSecurityContextRepository$Servlet3SaveToSessionRequestWrapper.startAsync(HttpSessionSecurityContextRepository.java:246)
at javax.servlet.ServletRequestWrapper.startAsync(ServletRequestWrapper.java:398)
at org.springframework.security.web.servletapi.HttpServlet3RequestFactory$Servlet3SecurityContextHolderAwareRequestWrapper.startAsync(HttpServlet3RequestFactory.java:173)
at org.atmosphere.cpr.AtmosphereRequestImpl.startAsync(AtmosphereRequestImpl.java:615)
at org.atmosphere.container.Servlet30CometSupport.suspend(Servlet30CometSupport.java:95)
at org.atmosphere.container.Servlet30CometSupport.service(Servlet30CometSupport.java:70)
at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:2285)
at org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:191)
at org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:177)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.jasig.cas.client.session.SingleSignOutFilter.doFilter(SingleSignOutFilter.java:65)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2500)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2489)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
... goes on and on ...
... I shutdown the server here ...
26-May-2016 17:44:18.151 INFO [main] org.apache.catalina.core.StandardServer.await A valid shutdown command was received via the shutdown port. Stopping the Server instance.
26-May-2016 17:44:18.152 INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-apr-8081"]
26-May-2016 17:44:18.204 INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["ajp-apr-8009"]
26-May-2016 17:44:18.255 INFO [main] org.apache.catalina.core.StandardService.stopInternal Arrêt du service Catalina
26-May-2016 17:44:18.289 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [jamon] appears to have started a thread named [JamonDataPersisterTimerTask-saveJamonData] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.util.TimerThread.mainLoop(Timer.java:552)
java.util.TimerThread.run(Timer.java:505)
17:44:18 | [ INFO] | [localhost-startStop-2] (AbstractApplicationContext.java:doClose:862) Closing Root WebApplicationContext: startup date [Thu May 26 17:41:15 CEST 2016]; root of context hierarchy
17:44:18 | [ INFO] | [localhost-startStop-2] (AbstractEntityManagerFactoryBean.java:destroy:462) Closing JPA EntityManagerFactory for persistence unit 'TIANA'
17:44:18 | [ INFO] | [localhost-startStop-2] (AbstractEntityManagerFactoryBean.java:destroy:462) Closing JPA EntityManagerFactory for persistence unit 'DISTRIB'
26-May-2016 17:44:18.552 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [tiana-webui] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@4aab79c8]) and a value of type [org.atmosphere.cpr.AtmosphereResourceImpl] (value [AtmosphereResource{
uuid=d9a48c99-dc69-4c38-8a58-b40908fb67fa,
transport=LONG_POLLING,
isInScope=true,
isResumed=false,
isCancelled=true,
isSuspended=false,
broadcasters=/notify/BOUVIERM,
isClosedByClient=false,
isClosedByApplication=false,
action=Action{timeout=-1, type=CANCELLED}}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
...
goes on and on
...
26-May-2016 17:44:19.137 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [tiana-webui] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@25d1d6d9]) and a value of type [org.atmosphere.cpr.AtmosphereResourceImpl] (value [AtmosphereResource{
uuid=d9a48c99-dc69-4c38-8a58-b40908fb67fa,
transport=LONG_POLLING,
isInScope=true,
isResumed=false,
isCancelled=true,
isSuspended=false,
broadcasters=/notify/BOUVIERM,
isClosedByClient=false,
isClosedByApplication=false,
action=Action{timeout=-1, type=CANCELLED}}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
26-May-2016 17:44:19.173 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-apr-8081"]
26-May-2016 17:44:19.239 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-apr-8009"]
26-May-2016 17:44:19.302 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-apr-8081"]
26-May-2016 17:44:19.302 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["ajp-apr-8009"]
Disconnected from server
稍微挖掘一下,似乎是IE9客户端试图重新连接的大量请求。
我发现了我的问题所在。我忘了在几个 <servlet>
和 <filter>
定义上添加 <async-supported>true</async-supported>
。
我正在尝试使用 primefaces push 来通知客户端事件。我调整了 Primefaces 通知展示,因此它可以与 spring 依赖注入框架一起使用。
JDK 1.8.0_u91, Tomcat 8.0.33, primefaces 5.3, atmosphere 2.4.2, atmosphere-spring 2.4.0
我的浏览器目标是 Internet Explorer 9。
用例如下:
- JSF 页面有一个
- 在 JSF 页面中,我单击了一个按钮,它触发了支持 bean 中的 send2() 方法
- send2() 发布消息到频道 /notify/BOUVIERM
- 在推送端点 (PushDemoResource) 中调用 onMessage() 方法
- 消息被发送回 JSF 页面,javascript 调用函数 handleMessage() 并在屏幕上显示消息。
此示例似乎适用于 firefox,并且 chrome 使用 websocket 协议。 不幸的是,在 Internet Explorer 9 中它回退到长轮询并发送大量请求。它在服务器端生成大量堆栈跟踪,并且在不到 1 分钟的时间内发送了大约 4000 个请求(发送了 3.5MB,接收了 8.5MB)。
您是否认为我配置有误?
非常感谢。
Maven 配置
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime</artifactId>
<version>2.4.2</version>
</dependency>
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-spring</artifactId>
<version>2.4.0</version>
</dependency>
web.xml
<!-- JSF mapping -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Map these files with JSF -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Push Servlet</servlet-name>
<servlet-class>org.primefaces.push.PushServlet</servlet-class>
<init-param>
<param-name>org.atmosphere.cpr.broadcasterCacheClass</param-name>
<param-value>org.atmosphere.cache.UUIDBroadcasterCache</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Push Servlet</servlet-name>
<url-pattern>/primepush/*</url-pattern>
</servlet-mapping>
JSF 页面
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
>
<f:view contentType="text/html">
<ui:composition template="/xhtml/template/layout.xhtml">
<ui:define name="headTitle">
<h:outputText value="Push POC"/>
</ui:define>
<ui:define name="center">
<h:form>
<p:commandButton actionListener="#{pushDemoController.send2}" value="Message simple : /notify/#{request.userPrincipal.name}"/>
</h:form>
<p:growl widgetVar="growlPush" showDetail="true"/>
<p:socket channel="/notify/#{request.userPrincipal.name}" onMessage="handleMessage" />
<script type="text/javascript">
function handleMessage(message) {
PF('growlPush').show([message]);
}
</script>
</ui:define>
</ui:composition>
</f:view>
</html>
托管 bean
import com.agipi.web.util.FacesUtils;
import org.primefaces.push.EventBus;
import org.primefaces.push.EventBusFactory;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import java.io.Serializable;
/**
* Controller servant d'exemple à l'utilisation du framework Push de primefaces.
* Created by devbouvier on 25/05/2016.
*/
@SuppressWarnings("serial")
@ManagedBean
@ApplicationScoped
public class PushDemoController implements Serializable {
public void send2() {
EventBus eventBus2 = EventBusFactory.getDefault().eventBus();
String channel = "/notify/" + FacesUtils.getPrincipal().getName();
eventBus2.publish(channel, "Message envoyé ");
}
}
推送端点
package com.agipi.g2a.tiana.web.controller.demo;
import com.agipi.web.util.FacesUtils;
import org.primefaces.push.EventBus;
import org.primefaces.push.RemoteEndpoint;
import org.primefaces.push.annotation.*;
import org.primefaces.push.impl.JSONEncoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.faces.application.FacesMessage;
import javax.inject.Inject;
import java.io.Serializable;
@PushEndpoint("/notify/{user}")
@Singleton
public class PushDemoResource implements Serializable {
private static final Logger LOGGER = LoggerFactory.getLogger(PushDemoResource.class);
@Inject
private EventBus eventBus;
@Inject
private RemoteEndpoint endpoint;
@PathParam(value = "user")
private String user;
@OnMessage(encoders = {JSONEncoder.class})
public FacesMessage onMessage(String message) {
LOGGER.info("Message recu : {} pour {}", message, user);
return FacesUtils.getMessage("Notification " + message + " pour " + user, FacesMessage.SEVERITY_INFO);
}
@OnClose
public void onClose(RemoteEndpoint r, EventBus e) {
LOGGER.info("Push Demo onClose : [remoteEndpoint={},eventBus={}]", r, e);
}
@OnOpen
public void onOpen(RemoteEndpoint r, EventBus e) {
LOGGER.info("Push Demo onOpen : [remoteEndpoint={},eventBus={}]", r, e);
}
}
启动时大气记录
18:03:59 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AbstractApplicationContext.java:prepareRefresh:510) Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@e123f5b: startup date [Thu May 26 18:03:59 CEST 2016]; parent: Root WebApplicationContext
18:03:59 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AutowiredAnnotationBeanPostProcessor.java:<init>:153) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
18:03:59 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:autoConfigureService:2828) Atmosphere is using org.atmosphere.cpr.DefaultAnnotationProcessor for processing annotation
18:03:59 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (DefaultAnnotationProcessor.java:configure:151) AnnotationProcessor class org.atmosphere.cpr.DefaultAnnotationProcessor$ServletContainerInitializerAnnotationProcessor being used
18:03:59 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AnnotationHandler.java:handleAnnotation:80) Found Annotation in class org.primefaces.push.impl.PushEndpointInterceptor being scanned: interface org.atmosphere.config.service.AtmosphereInterceptorService
18:03:59 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AnnotationHandler.java:handleAnnotation:80) Found Annotation in class org.primefaces.push.impl.PushEndpointProcessor being scanned: interface org.atmosphere.config.AtmosphereAnnotation
18:03:59 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AnnotationHandler.java:handleAnnotation:80) Found Annotation in class org.primefaces.push.impl.PushEndpointMapper being scanned: interface org.atmosphere.config.service.EndpointMapperService
18:03:59 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AnnotationHandler.java:handleAnnotation:80) Found Annotation in class com.agipi.g2a.tiana.web.controller.demo.PushDemoResource being scanned: interface org.primefaces.push.annotation.PushEndpoint
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (ForkJoinPool.java:<init>:48) Using ForkJoinPool java.util.concurrent.ForkJoinPool. Set the org.atmosphere.cpr.broadcaster.maxAsyncWriteThreads to -1 to fully use its power.
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addAtmosphereHandler:638) Installed AtmosphereHandler org.primefaces.push.impl.PushEndpointHandlerProxy mapped to context-path /notify/{user} and Broadcaster Class org.atmosphere.cpr.DefaultBroadcaster
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addAtmosphereHandler:646) Installed AtmosphereInterceptor [@PushEndpoint Interceptor] mapped to AtmosphereHandler org.primefaces.push.impl.PushEndpointHandlerProxy
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:autoDetectWebSocketHandler:2154) Auto detecting WebSocketHandler in /WEB-INF/classes/
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:initWebSocket:1762) Installed WebSocketProtocol org.atmosphere.websocket.protocol.SimpleHttpProtocol
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (JSR356AsyncSupport.java:<init>:68) JSR 356 Mapping path /primepush
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:configureAtmosphereInterceptor:1226) Installing Default AtmosphereInterceptors
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:newAInterceptor:1245) org.atmosphere.interceptor.CorsInterceptor : CORS Interceptor Support
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:newAInterceptor:1245) org.atmosphere.interceptor.CacheHeadersInterceptor : Default Response's Headers Interceptor
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:newAInterceptor:1245) org.atmosphere.interceptor.PaddingAtmosphereInterceptor : Browser Padding Interceptor Support
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:newAInterceptor:1245) org.atmosphere.interceptor.AndroidAtmosphereInterceptor : Android Interceptor Support
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:newAInterceptor:1245) org.atmosphere.interceptor.HeartbeatInterceptor : Heartbeat Interceptor Support
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:newAInterceptor:1245) org.atmosphere.interceptor.SSEAtmosphereInterceptor : SSE Interceptor Support
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:newAInterceptor:1245) org.atmosphere.interceptor.JSONPAtmosphereInterceptor : JSONP Interceptor Support
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:newAInterceptor:1245) org.atmosphere.interceptor.JavaScriptProtocol : Atmosphere JavaScript Protocol
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:newAInterceptor:1245) org.atmosphere.interceptor.WebSocketMessageSuspendInterceptor : org.atmosphere.interceptor.WebSocketMessageSuspendInterceptor
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:newAInterceptor:1245) org.atmosphere.interceptor.OnDisconnectInterceptor : Browser disconnection detection
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:newAInterceptor:1245) org.atmosphere.interceptor.IdleResourceInterceptor : org.atmosphere.interceptor.IdleResourceInterceptor
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:configureAtmosphereInterceptor:1235) Set org.atmosphere.cpr.AtmosphereInterceptor.disableDefaults to disable them.
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor Atmosphere LifeCycle with priority AFTER_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor Track Message Size Interceptor using | with priority BEFORE_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor @PushEndpoint Interceptor with priority AFTER_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor CORS Interceptor Support with priority FIRST_BEFORE_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor Default Response's Headers Interceptor with priority AFTER_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor Browser Padding Interceptor Support with priority AFTER_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor Android Interceptor Support with priority AFTER_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (HeartbeatInterceptor.java:configure:169) HeartbeatInterceptor configured with padding value 'X', client frequency 60 seconds and server frequency 1 seconds
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor Heartbeat Interceptor Support with priority AFTER_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor SSE Interceptor Support with priority AFTER_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor JSONP Interceptor Support with priority AFTER_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor Atmosphere JavaScript Protocol with priority AFTER_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor org.atmosphere.interceptor.WebSocketMessageSuspendInterceptor with priority AFTER_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor Browser disconnection detection with priority AFTER_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:addInterceptorToAllWrappers:2619) Installed AtmosphereInterceptor org.atmosphere.interceptor.IdleResourceInterceptor with priority BEFORE_DEFAULT
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1039) Using EndpointMapper class org.primefaces.push.impl.PushEndpointMapper
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1048) Using BroadcasterCache: org.atmosphere.cache.UUIDBroadcasterCache
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1053) Default Broadcaster Class: org.atmosphere.cpr.DefaultBroadcaster
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1054) Broadcaster Shared List Resources: false
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1055) Broadcaster Polling Wait Time 100
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1056) Shared ExecutorService supported: true
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1065) Messaging ExecutorService Pool Size unavailable - Not instance of ThreadPoolExecutor
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1072) Async I/O Thread Pool Size: 200
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1078) Using BroadcasterFactory: org.atmosphere.cpr.DefaultBroadcasterFactory
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1079) Using AtmosphereResurceFactory: org.atmosphere.cpr.DefaultAtmosphereResourceFactory
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1080) Using WebSocketProcessor: org.atmosphere.websocket.DefaultWebSocketProcessor
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1090) Invoke AtmosphereInterceptor on WebSocket message true
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1091) HttpSession supported: false
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1093) Atmosphere is using Spring Web ObjectFactory for dependency injection and object creation
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1094) Atmosphere is using async support: org.atmosphere.container.JSR356AsyncSupport running under container: Apache Tomcat/8.0.33 using javax.servlet/3.0 and jsr356/WebSocket API
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1096) Atmosphere Framework 2.4.2 started.
18:04:00 | [ INFO] | [RMI TCP Connection(3)-127.0.0.1] (AtmosphereFramework.java:info:1098)
For Atmosphere Framework Commercial Support, visit
http://www.async-io.org/ or send an email to support@async-io.org
[2016-05-26 06:04:00,354] Artifact tiana-webui (2):war exploded: Artifact is deployed successfully
[2016-05-26 06:04:00,355] Artifact tiana-webui (2):war exploded: Deploy took 33 427 milliseconds
18:04:00 | [ INFO] | [Thread-15] (AtmosphereFramework.java:run:1174) Latest version of Atmosphere's JavaScript Client 2.3.1
18:04:00 | [ INFO] | [Thread-15] (AtmosphereFramework.java:run:1182)
Atmosphere Framework Updates:
Major Update available (new features): 2.4.3
服务器堆栈跟踪
17:44:17 | [ WARN] | [http-apr-8081-exec-8] (DefaultBroadcaster.java:addAtmosphereResource:1366) Duplicate resource d9a48c99-dc69-4c38-8a58-b40908fb67fa. Could be caused by a dead connection not detected by your server. Replacing the old one with the fresh one
17:44:17 | [ERROR] | [http-apr-8081-exec-8] (AtmosphereFramework.java:doCometSupport:2307) AtmosphereFramework exception
java.lang.IllegalStateException: A filter or servlet of the current chain does not support asynchronous operations.
at org.apache.catalina.connector.Request.startAsync(Request.java:1621)
at org.apache.catalina.connector.RequestFacade.startAsync(RequestFacade.java:1037)
at javax.servlet.ServletRequestWrapper.startAsync(ServletRequestWrapper.java:398)
at javax.servlet.ServletRequestWrapper.startAsync(ServletRequestWrapper.java:398)
at org.springframework.security.web.context.HttpSessionSecurityContextRepository$Servlet3SaveToSessionRequestWrapper.startAsync(HttpSessionSecurityContextRepository.java:246)
at javax.servlet.ServletRequestWrapper.startAsync(ServletRequestWrapper.java:398)
at org.springframework.security.web.servletapi.HttpServlet3RequestFactory$Servlet3SecurityContextHolderAwareRequestWrapper.startAsync(HttpServlet3RequestFactory.java:173)
at org.atmosphere.cpr.AtmosphereRequestImpl.startAsync(AtmosphereRequestImpl.java:615)
at org.atmosphere.container.Servlet30CometSupport.suspend(Servlet30CometSupport.java:95)
at org.atmosphere.container.Servlet30CometSupport.service(Servlet30CometSupport.java:70)
at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:2285)
at org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:191)
at org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:177)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.jasig.cas.client.session.SingleSignOutFilter.doFilter(SingleSignOutFilter.java:65)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2500)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2489)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
... goes on and on ...
... I shutdown the server here ...
26-May-2016 17:44:18.151 INFO [main] org.apache.catalina.core.StandardServer.await A valid shutdown command was received via the shutdown port. Stopping the Server instance.
26-May-2016 17:44:18.152 INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-apr-8081"]
26-May-2016 17:44:18.204 INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["ajp-apr-8009"]
26-May-2016 17:44:18.255 INFO [main] org.apache.catalina.core.StandardService.stopInternal Arrêt du service Catalina
26-May-2016 17:44:18.289 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [jamon] appears to have started a thread named [JamonDataPersisterTimerTask-saveJamonData] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.util.TimerThread.mainLoop(Timer.java:552)
java.util.TimerThread.run(Timer.java:505)
17:44:18 | [ INFO] | [localhost-startStop-2] (AbstractApplicationContext.java:doClose:862) Closing Root WebApplicationContext: startup date [Thu May 26 17:41:15 CEST 2016]; root of context hierarchy
17:44:18 | [ INFO] | [localhost-startStop-2] (AbstractEntityManagerFactoryBean.java:destroy:462) Closing JPA EntityManagerFactory for persistence unit 'TIANA'
17:44:18 | [ INFO] | [localhost-startStop-2] (AbstractEntityManagerFactoryBean.java:destroy:462) Closing JPA EntityManagerFactory for persistence unit 'DISTRIB'
26-May-2016 17:44:18.552 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [tiana-webui] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@4aab79c8]) and a value of type [org.atmosphere.cpr.AtmosphereResourceImpl] (value [AtmosphereResource{
uuid=d9a48c99-dc69-4c38-8a58-b40908fb67fa,
transport=LONG_POLLING,
isInScope=true,
isResumed=false,
isCancelled=true,
isSuspended=false,
broadcasters=/notify/BOUVIERM,
isClosedByClient=false,
isClosedByApplication=false,
action=Action{timeout=-1, type=CANCELLED}}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
...
goes on and on
...
26-May-2016 17:44:19.137 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [tiana-webui] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@25d1d6d9]) and a value of type [org.atmosphere.cpr.AtmosphereResourceImpl] (value [AtmosphereResource{
uuid=d9a48c99-dc69-4c38-8a58-b40908fb67fa,
transport=LONG_POLLING,
isInScope=true,
isResumed=false,
isCancelled=true,
isSuspended=false,
broadcasters=/notify/BOUVIERM,
isClosedByClient=false,
isClosedByApplication=false,
action=Action{timeout=-1, type=CANCELLED}}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
26-May-2016 17:44:19.173 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-apr-8081"]
26-May-2016 17:44:19.239 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-apr-8009"]
26-May-2016 17:44:19.302 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-apr-8081"]
26-May-2016 17:44:19.302 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["ajp-apr-8009"]
Disconnected from server
稍微挖掘一下,似乎是IE9客户端试图重新连接的大量请求。
我发现了我的问题所在。我忘了在几个 <servlet>
和 <filter>
定义上添加 <async-supported>true</async-supported>
。