Websockets on JBoss EAP 6.1(AS 7.2.0) and Primefaces Push
gboro54 May 31, 2013 7:55 AMHi!
We are currently trying to get primefaces push to use websockets on JBoss eap 6.1.0(AS 7.2.0). We are currently configured as follows:
standalone-full.xml
standalone-full.xml
{code:xml}
<subsystem xmlns="urn:jboss:domain:web:1.4" default-virtual-server="default-host" native="true">
<connector name="ajp" protocol="AJP/1.3" scheme="http" socket-binding="ajp"/>
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
<virtual-server name="default-host" enable-welcome-root="true">
<alias name="localhost"/>
<alias name="example.com"/>
</virtual-server>
</subsystem>
{code:xml}
web.xml
{code:xml}
<servlet>
<servlet-name>pushServlet</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.HeaderBroadcasterCache</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.cpr.asyncSupport</param-name>
<param-value>org.atmosphere.container.JBossWebSocketSupport</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.useNative</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.cpr.AtmosphereServlet.resumeAndKeepAlive</param-name>
<param-value>true</param-value>
</init-param>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>pushServlet</servlet-name>
<url-pattern>/primepush/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>600</session-timeout>
</session-config>
{code:xml}
socket:
{code:xml}
<p:socket widgetVar="notifier" channel="/notifications/#{sessionBean.user.user.id}"
onMessage="handleNotification" transport="websocket" fallbackTransport="websocket" autoConnect="false" >
<p:ajax update="navbar2" immediate="true" />
</p:socket>
{code:xml}
pom.xml(dependencies)
{code:xml}
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime</artifactId>
<version>1.1.0.RC2</version>
</dependency>
<dependency>
<groupId>org.atmosphere.jboss.as</groupId>
<artifactId>jboss-as-websockets</artifactId>
<version>0.4</version>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>afterwork</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>primefaces-extensions</artifactId>
<version>0.6.3</version>
</dependency>
{code:xml}
With this setup I see the following on the client side:
firefox v 21.0 - Websocket failed. Downgrading to Comet and resending
chrome v 27.0.1453.94 m
[code]
WebSocket connection to 'ws://127.0.0.1:8080/fbms/primepush/notifications/B006?X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=1.0.8&X-Atmosphere-Transport=websocket&X-Cache-Date=0' failed: Unexpected response code: 200http://127.0.0.1:8080/fbms/?windowId=00c
Websocket closed, reason: Connection was closed abnormally (that is, with no close frame being sent). push.js.jsf:1
Websocket closed, wasClean: false push.js.jsf:1
Websocket failed. Downgrading to Comet and resending
[/code]
Turning on Trace on the server side I see the following:
{code}
07:46:35,467 TRACE [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) : java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer from [Module "deployment.fbms-ear-1.1.9-SNAPSHOT.ear.fbms-web-1.1.9-SNAPSHOT.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:196) [jboss-modules.jar:1.2.0.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:444) [jboss-modules.jar:1.2.0.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:432) [jboss-modules.jar:1.2.0.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:374) [jboss-modules.jar:1.2.0.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:119) [jboss-modules.jar:1.2.0.Final-redhat-1]
at org.atmosphere.cpr.AtmosphereFramework.detectSupportedFramework(AtmosphereFramework.java:914) [atmosphere-runtime-1.1.0.RC2.jar:1.1.0.RC2]
at org.atmosphere.cpr.AtmosphereFramework.loadConfiguration(AtmosphereFramework.java:890) [atmosphere-runtime-1.1.0.RC2.jar:1.1.0.RC2]
at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:565) [atmosphere-runtime-1.1.0.RC2.jar:1.1.0.RC2]
at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:499) [atmosphere-runtime-1.1.0.RC2.jar:1.1.0.RC2]
at org.atmosphere.cpr.AtmosphereServlet.init(AtmosphereServlet.java:195) [atmosphere-runtime-1.1.0.RC2.jar:1.1.0.RC2]
at org.primefaces.push.PushServlet.init(PushServlet.java:46) [primefaces-3.5.jar:]
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1194) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:950) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:151) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:481) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_31]
07:46:35,549 INFO [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) Auto detecting WebSocketHandler in /WEB-INF/classes/
07:46:35,556 INFO [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) Atmosphere is using async support: org.atmosphere.container.JBossWebSocketSupport running under container: JBoss Web/7.2.0.Final-redhat-1
07:46:35,557 INFO [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) Installing Default AtmosphereInterceptor
07:46:35,562 INFO [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) org.atmosphere.interceptor.OnDisconnectInterceptor : Browser disconnection detection
07:46:35,565 INFO [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) org.atmosphere.interceptor.JavaScriptProtocol : Atmosphere JavaScript Protocol
07:46:35,573 INFO [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) org.atmosphere.interceptor.JSONPAtmosphereInterceptor : JSONP Interceptor Support
07:46:35,607 INFO [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) org.atmosphere.interceptor.SSEAtmosphereInterceptor : SSE Interceptor Support
07:46:35,609 INFO [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) org.atmosphere.interceptor.AndroidAtmosphereInterceptor : Android Interceptor Support
07:46:35,612 INFO [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) org.atmosphere.interceptor.PaddingAtmosphereInterceptor : Browser Padding Interceptor Support
07:46:35,613 INFO [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) org.atmosphere.interceptor.DefaultHeadersInterceptor : Default Response's Headers Interceptor
07:46:35,613 INFO [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) Set org.atmosphere.cpr.AtmosphereInterceptor.disableDefaults in your xml to disable them.
07:46:35,614 INFO [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) Using BroadcasterCache: org.atmosphere.cache.HeaderBroadcasterCache
07:46:35,615 INFO [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) Shared ExecutorService supported: true
07:46:35,615 INFO [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) HttpSession supported: false
07:46:35,615 INFO [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) Using BroadcasterFactory: org.atmosphere.cpr.DefaultBroadcasterFactory
07:46:35,615 INFO [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) Using WebSocketProcessor: org.atmosphere.websocket.DefaultWebSocketProcessor
07:46:35,621 INFO [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) Using Broadcaster: org.atmosphere.cpr.DefaultBroadcaster
07:46:35,622 INFO [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) Atmosphere Framework 1.1.0.RC2 started.
07:46:35,623 INFO [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7)
For Commercial Support, visit
http://www.async-io.org/ or send an email to support@async-io.org
07:46:35,639 INFO [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) Installed AtmosphereInterceptor Atmosphere LifeCycle.
07:46:35,641 TRACE [org.atmosphere.cpr.DefaultBroadcasterFactory] (http-/127.0.0.1:8080-7) About to create /*
07:46:35,650 TRACE [org.atmosphere.cpr.DefaultBroadcasterFactory] (http-/127.0.0.1:8080-7) Looking in the store using /* returned null
07:46:35,669 TRACE [org.atmosphere.cpr.DefaultBroadcasterFactory] (http-/127.0.0.1:8080-7) About to create /*
07:46:35,670 TRACE [org.atmosphere.cpr.DefaultBroadcasterFactory] (http-/127.0.0.1:8080-7) Looking in the store using /* returned null
07:46:35,671 TRACE [org.atmosphere.cpr.DefaultBroadcasterFactory] (http-/127.0.0.1:8080-7) Broadcaster /* was created
Name: /*
Scope: APPLICATION
BroasdcasterCache org.atmosphere.cache.HeaderBroadcasterCache@6b8b78a1
AtmosphereResource: 0
org.atmosphere.cpr.DefaultBroadcaster@295487792
07:46:35,674 INFO [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) Installed AtmosphereHandler org.primefaces.push.PrimeAtmosphereHandler mapped to context-path: /*
07:46:35,680 INFO [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) Installed the following AtmosphereInterceptor mapped to AtmosphereHandler org.primefaces.push.PrimeAtmosphereHandler
07:46:35,683 TRACE [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-7) Query String translated to headers {X-Atmosphere-Transport=websocket, X-Atmosphere-Framework=1.0.8, X-Atmosphere-tracking-id=0, X-Cache-Date=0}
07:46:35,688 TRACE [org.atmosphere.cpr.DefaultBroadcasterFactory] (http-/127.0.0.1:8080-7) About to create /notifications/B006
07:46:35,688 TRACE [org.atmosphere.cpr.DefaultBroadcasterFactory] (http-/127.0.0.1:8080-7) Looking in the store using /notifications/B006 returned null
07:46:35,689 TRACE [org.atmosphere.cpr.DefaultBroadcasterFactory] (http-/127.0.0.1:8080-7) About to create /notifications/B006
07:46:35,693 TRACE [org.atmosphere.cpr.DefaultBroadcasterFactory] (http-/127.0.0.1:8080-7) Looking in the store using /notifications/B006 returned null
07:46:35,693 TRACE [org.atmosphere.cpr.DefaultBroadcasterFactory] (http-/127.0.0.1:8080-7) Broadcaster /notifications/B006 was created
Name: /notifications/B006
Scope: APPLICATION
BroasdcasterCache org.atmosphere.cache.HeaderBroadcasterCache@6ba2e1a8
AtmosphereResource: 0
org.atmosphere.cpr.DefaultBroadcaster@311235533
07:46:35,714 TRACE [org.atmosphere.cpr.AtmosphereResourceEventListener] (http-/127.0.0.1:8080-7) AtmosphereResourceEventImpl{isCancelled=false,
isResumedOnTimeout=false,
throwable=null,
message=null,
resource=AtmosphereResourceImpl{
uuid=4a95a2c8-fc36-48ed-8f79-2a23a18ddc92,
transport=WEBSOCKET,
action=Action{timeout=-1, type=CREATED},
isResumed=false,
isCancelled=false,
isSuspended=false,
broadcaster=/notifications/B006,
isInScope=true,
listeners=[org.atmosphere.interceptor.AtmosphereResourceLifecycleInterceptor$1@54691672]}}
07:46:35,743 TRACE [org.atmosphere.cpr.DefaultBroadcaster] (http-/127.0.0.1:8080-7) Checking cached message for 4a95a2c8-fc36-48ed-8f79-2a23a18ddc92
07:46:35,744 TRACE [org.atmosphere.cpr.DefaultBroadcaster] (http-/127.0.0.1:8080-7) Associating AtmosphereResource 4a95a2c8-fc36-48ed-8f79-2a23a18ddc92 with Broadcaster /notifications/B006
07:46:35,751 TRACE [org.atmosphere.cpr.AtmosphereResourceImpl] (http-/127.0.0.1:8080-7) Invoking listener with AtmosphereResourceEventImpl{isCancelled=false,
isResumedOnTimeout=false,
throwable=null,
message=null,
resource=AtmosphereResourceImpl{
uuid=4a95a2c8-fc36-48ed-8f79-2a23a18ddc92,
transport=WEBSOCKET,
action=Action{timeout=-1, type=SUSPEND},
isResumed=false,
isCancelled=false,
isSuspended=true,
broadcaster=/notifications/B006,
isInScope=true,
listeners=[org.atmosphere.interceptor.AtmosphereResourceLifecycleInterceptor$1@54691672]}}
07:46:35,791 TRACE [org.atmosphere.cpr.AtmosphereResourceEventListener] (http-/127.0.0.1:8080-7) AtmosphereResourceEventImpl{isCancelled=false,
isResumedOnTimeout=false,
throwable=null,
message=null,
resource=AtmosphereResourceImpl{
uuid=4a95a2c8-fc36-48ed-8f79-2a23a18ddc92,
transport=WEBSOCKET,
action=Action{timeout=-1, type=SUSPEND},
isResumed=false,
isCancelled=false,
isSuspended=true,
broadcaster=/notifications/B006,
isInScope=true,
listeners=[org.atmosphere.interceptor.AtmosphereResourceLifecycleInterceptor$1@54691672]}}
07:46:35,825 TRACE [org.atmosphere.cpr.AsynchronousProcessor] (http-/127.0.0.1:8080-7) Action for 4a95a2c8-fc36-48ed-8f79-2a23a18ddc92 was Action{timeout=-1, type=SUSPEND}
07:46:35,827 TRACE [org.atmosphere.cpr.AsyncSupportListenerAdapter] (http-/127.0.0.1:8080-7) Suspended request 4a95a2c8-fc36-48ed-8f79-2a23a18ddc92 and response AtmosphereResponse{cookies=[], headers={Access-Control-Allow-Origin=http://127.0.0.1:8080, Expires=-1, Access-Control-Allow-Credentials=true, X-Atmosphere-tracking-id=4a95a2c8-fc36-48ed-8f79-2a23a18ddc92, X-Cache-Date=2156962802120885, Pragma=no-cache, Cache-Control=no-store, no-cache, must-revalidate}, asyncIOWriter=null, status=200, statusMessage='OK', charSet='UTF-8', contentLength=-1, contentType='text/html', isCommited=false, locale=null, headerHandled=false, atmosphereRequest=4a95a2c8-fc36-48ed-8f79-2a23a18ddc92, writeStatusAndHeader=true, delegateToNativeResponse=true, destroyable=true, response=org.apache.catalina.connector.ResponseFacade@1f9c097f}
07:46:35,839 TRACE [org.atmosphere.cpr.AsyncSupportListenerAdapter] (http-/127.0.0.1:8080-7) Suspended request 4a95a2c8-fc36-48ed-8f79-2a23a18ddc92 and response AtmosphereResponse{cookies=[], headers={Access-Control-Allow-Origin=http://127.0.0.1:8080, Expires=-1, Access-Control-Allow-Credentials=true, X-Atmosphere-tracking-id=4a95a2c8-fc36-48ed-8f79-2a23a18ddc92, X-Cache-Date=2156962802120885, Pragma=no-cache, Cache-Control=no-store, no-cache, must-revalidate}, asyncIOWriter=null, status=200, statusMessage='OK', charSet='UTF-8', contentLength=-1, contentType='text/html', isCommited=false, locale=null, headerHandled=false, atmosphereRequest=4a95a2c8-fc36-48ed-8f79-2a23a18ddc92, writeStatusAndHeader=true, delegateToNativeResponse=true, destroyable=true, response=org.apache.catalina.connector.ResponseFacade@1f9c097f}
07:46:35,859 TRACE [org.atmosphere.cpr.AtmosphereFramework] (http-/127.0.0.1:8080-3) Query String translated to headers {X-Atmosphere-Transport=long-polling, X-Atmosphere-Framework=1.0.8, _=1370000795857, X-Atmosphere-tracking-id=0, X-Cache-Date=0}
07:46:35,863 TRACE [org.atmosphere.cpr.DefaultBroadcasterFactory] (http-/127.0.0.1:8080-3) About to create /notifications/B006
07:46:35,865 TRACE [org.atmosphere.cpr.DefaultBroadcasterFactory] (http-/127.0.0.1:8080-3) Looking in the store using /notifications/B006 returned
Name: /notifications/B006
Scope: APPLICATION
BroasdcasterCache org.atmosphere.cache.HeaderBroadcasterCache@6ba2e1a8
AtmosphereResource: 1
org.atmosphere.cpr.DefaultBroadcaster@311235533
07:46:35,885 TRACE [org.atmosphere.cpr.AtmosphereResourceEventListener] (http-/127.0.0.1:8080-3) AtmosphereResourceEventImpl{isCancelled=false,
isResumedOnTimeout=false,
throwable=null,
message=null,
resource=AtmosphereResourceImpl{
uuid=f4b5e210-a680-41ce-9f4d-74619099047d,
transport=LONG_POLLING,
action=Action{timeout=-1, type=CREATED},
isResumed=false,
isCancelled=false,
isSuspended=false,
broadcaster=/notifications/B006,
isInScope=true,
listeners=[org.atmosphere.interceptor.PaddingAtmosphereInterceptor$1@1b65cb8, org.atmosphere.interceptor.AtmosphereResourceLifecycleInterceptor$1@6b8134e8]}}
07:46:35,916 TRACE [org.atmosphere.cpr.DefaultBroadcaster] (http-/127.0.0.1:8080-3) Checking cached message for f4b5e210-a680-41ce-9f4d-74619099047d
{code}
As you can see, for some reason the websocket is closed and reverted to long-polling. Am I missing something in my configuration? Any help would be greatly appreciated