Hello,
I am getting a NullPointerException when ivoking the HelloService
example on GlassFish using a WebSocket enabled browser. I have tested
this using Chrome 8.0.552.224. It fails to connect using WebSockets
and eventually switches to long-polling mode, which works fine. Yet an
exception is thrown on the server. See below for the complete debug
enabled server output.
Is there any way of getting WebSockets to work with cometd on
Glassfish (Jetty libraries embedded)?
Thanks for your advice.
Christian
=========
My Setup:
=========
Server: Glassfish Server Open Source Edition 3.1-b30 (build 30) with
Jetty v7.1.5.v20100705 Libraries.
Comet Libraries: cometd 2.0.0
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="
http://java.sun.com/xml/ns/javaee"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<servlet>
<servlet-name>cometd</servlet-name>
<servlet-class>org.cometd.server.CometdServlet</servlet-class>
<init-param>
<!-- The log level; 0 = warn, 1 = info, 2 = debug -->
<param-name>logLevel</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>cometd</servlet-name>
<url-pattern>/cometd/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>initializer</servlet-name>
<servlet-class>mein.BayeuxInitializer</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<filter>
<filter-name>cross-origin</filter-name>
<filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</
filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>cross-origin</filter-name>
<url-pattern>/cometd/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>
Listening for transport dt_socket at address: 53694
SEVERE: 2010-12-16 13:14:56.234:INFO:bayeux@2001113342:interval=0
SEVERE: 2010-12-16 13:14:56.234:INFO:bayeux@2001113342:jsonDebug=false
SEVERE: 2010-12-16 13:14:56.234:INFO:bayeux@2001113342:long-
polling.autoBatch=true
SEVERE: 2010-12-16 13:14:56.235:INFO:bayeux@2001113342:long-
polling.browserId=BAYEUX_BROWSER
SEVERE: 2010-12-16 13:14:56.235:INFO:bayeux@2001113342:long-
polling.json.metaConnectDeliverOnly=false
SEVERE: 2010-12-16 13:14:56.235:INFO:bayeux@2001113342:long-
polling.json.mimeType=application/json;charset=UTF-8
SEVERE: 2010-12-16 13:14:56.235:INFO:bayeux@2001113342:long-
polling.jsonp.callbackParameter=jsonp
SEVERE: 2010-12-16 13:14:56.235:INFO:bayeux@2001113342:long-
polling.jsonp.metaConnectDeliverOnly=true
SEVERE: 2010-12-16 13:14:56.235:INFO:bayeux@2001113342:long-
polling.jsonp.mimeType=text/javascript;charset=UTF-8
SEVERE: 2010-12-16 13:14:56.236:INFO:bayeux@2001113342:long-
polling.maxSessionsPerBrowser=1
SEVERE: 2010-12-16 13:14:56.335:INFO:bayeux@2001113342:long-
polling.multiSessionInterval=2000
SEVERE: 2010-12-16
13:14:56.335:INFO:bayeux@2001113342:maxInterval=10000
SEVERE: 2010-12-16
13:14:56.335:INFO:bayeux@2001113342:maxLazyTimeout=5000
SEVERE: 2010-12-16
13:14:56.335:INFO:bayeux@2001113342:metaConnectDeliverOnly=false
SEVERE: 2010-12-16
13:14:56.335:INFO:bayeux@2001113342:sweepIntervalMs=997
SEVERE: 2010-12-16
13:14:56.335:INFO:bayeux@2001113342:tickIntervalMs=97
SEVERE: 2010-12-16 13:14:56.335:INFO:bayeux@2001113342:timeout=10000
SEVERE: 2010-12-16
13:14:56.335:INFO:bayeux@2001113342:ws.bufferSize=8192
SEVERE: 2010-12-16
13:14:56.336:INFO:bayeux@2001113342:ws.interval=2500
SEVERE: 2010-12-16
13:14:56.336:INFO:bayeux@2001113342:ws.maxInterval=15000
SEVERE: 2010-12-16
13:14:56.336:INFO:bayeux@2001113342:ws.metaConnectDeliverOnly=false
SEVERE: 2010-12-16 13:14:56.336:INFO:bayeux@2001113342:ws.protocol=
SEVERE: 2010-12-16
13:14:56.336:INFO:bayeux@2001113342:ws.timeout=15000
SEVERE: 2010-12-16 13:14:56.448:DBUG:bayeux@2001113342:> {"channel":"/
meta/handshake","id":"1"} hello_11tnmxr4fgqaa31h21g4ncrftg1
SEVERE: 2010-12-16 13:14:56.448:DBUG:bayeux@2001113342:>> {"channel":"/
meta/handshake","id":"1"}
SEVERE: 2010-12-16 13:14:56.451:DBUG:bayeux@2001113342:<< {"channel":"/
meta/
handshake","clientId":"hello_11tnmxr4fgqaa31h21g4ncrftg1","version":"1.0","successful":true,"minimumVersion":"1.0","id":"1","supportedConnectionTypes":
["websocket","long-polling","callback-polling"]}
SEVERE: 2010-12-16 13:14:56.451:DBUG:bayeux@2001113342:< {"channel":"/
meta/
handshake","clientId":"hello_11tnmxr4fgqaa31h21g4ncrftg1","version":"1.0","successful":true,"minimumVersion":"1.0","id":"1","supportedConnectionTypes":
["websocket","long-polling","callback-polling"]}
SEVERE: 2010-12-16 13:14:56.554:DBUG:bayeux@2001113342:> {"channel":"/
meta/connect","clientId":"hello_11tnmxr4fgqaa31h21g4ncrftg1","advice":
{"interval":-1},"id":"2"} hello_11tnmxr4fgqaa31h21g4ncrftg1
SEVERE: 2010-12-16 13:14:56.554:DBUG:bayeux@2001113342:>> {"channel":"/
meta/connect","clientId":"hello_11tnmxr4fgqaa31h21g4ncrftg1","advice":
{"interval":-1},"id":"2"}
SEVERE: 2010-12-16 13:14:56.649:DBUG:bayeux@2001113342:<< {"channel":"/
meta/connect","successful":true,"id":"2"}
SEVERE: 2010-12-16 13:14:56.649:DBUG:bayeux@2001113342:< {"channel":"/
meta/connect","successful":true,"id":"2"}
SEVERE: 2010-12-16 13:14:56.650:DBUG:bayeux@2001113342:subscribe
hello#processHello to /service/hello
SEVERE: 2010-12-16 13:14:56.651:DBUG:bayeux@2001113342:added /service
SEVERE: 2010-12-16 13:14:56.651:DBUG:bayeux@2001113342:added /service/
hello
INFO: WEB0671: Loading application [WebApplication1] at [/
WebApplication1]
INFO: WebApplication1 was successfully deployed in 4.333 milliseconds.
WARNUNG: StandardWrapperValve[cometd]: PWC1406: Servlet.service() for
servlet cometd threw exception
java.lang.NullPointerException
at
org.eclipse.jetty.websocket.WebSocketFactory.upgrade(WebSocketFactory.java:
92)
at
org.cometd.server.transport.WebSocketTransport.handle(WebSocketTransport.java:
93)
at org.cometd.server.CometdServlet.service(CometdServlet.java:
201)
at org.cometd.server.CometdServlet.service(CometdServlet.java:
165)
at
org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:
1534)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
343)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
215)
at
org.eclipse.jetty.servlets.CrossOriginFilter.handle(CrossOriginFilter.java:
186)
at
org.eclipse.jetty.servlets.CrossOriginFilter.doFilter(CrossOriginFilter.java:
158)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
256)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
215)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
279)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
175)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:
655)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:
595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:
98)
at
com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:
91)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
162)
at
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:
326)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
227)
at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:
170)
at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:
817)
at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:718)
at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1007)
at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:
225)
at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:
137)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
104)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
90)
at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:
79)
at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:
54)
at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:
59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool
$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool
$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:619)
SEVERE: 2010-12-16 13:15:50.563:DBUG:bayeux@2001113342:> {"channel":"/
meta/handshake","advice":{"timeout":60000,"interval":
0},"version":"1.0","minimumVersion":"0.9","id":"2","supportedConnectionTypes":
["long-polling","callback-polling"]} null
SEVERE: 2010-12-16 13:15:50.564:DBUG:bayeux@2001113342:>> {"channel":"/
meta/handshake","advice":{"timeout":60000,"interval":
0},"version":"1.0","minimumVersion":"0.9","id":"2","supportedConnectionTypes":
["long-polling","callback-polling"]}
SEVERE: 2010-12-16 13:15:50.565:DBUG:bayeux@2001113342:<< {"channel":"/
meta/
handshake","clientId":"219uwok9hspick1n5and5qda4w6","version":"1.0","successful":true,"minimumVersion":"1.0","id":"2","supportedConnectionTypes":
["websocket","long-polling","callback-polling"]}
SEVERE: 2010-12-16 13:15:50.565:DBUG:bayeux@2001113342:< {"channel":"/
meta/
handshake","clientId":"219uwok9hspick1n5and5qda4w6","version":"1.0","successful":true,"minimumVersion":"1.0","id":"2","supportedConnectionTypes":
["websocket","long-polling","callback-polling"]}
SEVERE: 2010-12-16 13:15:50.711:DBUG:bayeux@2001113342:> {"channel":"/
meta/
subscribe","clientId":"219uwok9hspick1n5and5qda4w6","id":"3","subscription":"/
hello"} 219uwok9hspick1n5and5qda4w6
SEVERE: 2010-12-16 13:15:50.711:DBUG:bayeux@2001113342:>> {"channel":"/
meta/
subscribe","clientId":"219uwok9hspick1n5and5qda4w6","id":"3","subscription":"/
hello"}
SEVERE: 2010-12-16 13:15:50.764:DBUG:bayeux@2001113342:added /hello
SEVERE: 2010-12-16 13:15:50.764:DBUG:bayeux@2001113342:<< {"channel":"/
meta/subscribe","successful":true,"id":"3","subscription":"/hello"}
SEVERE: 2010-12-16 13:15:50.765:DBUG:bayeux@2001113342:< {"channel":"/
meta/subscribe","successful":true,"id":"3","subscription":"/hello"}
SEVERE: 2010-12-16 13:15:50.765:DBUG:bayeux@2001113342:> {"channel":"/
service/hello","clientId":"219uwok9hspick1n5and5qda4w6","data":
{"name":"World"},"id":"4"} 219uwok9hspick1n5and5qda4w6
SEVERE: 2010-12-16 13:15:50.865:DBUG:bayeux@2001113342:>> {"channel":"/
service/hello","clientId":"219uwok9hspick1n5and5qda4w6","data":
{"name":"World"},"id":"4"}
SEVERE: 2010-12-16 13:15:50.865:DBUG:bayeux@2001113342:< {"channel":"/
service/hello","data":{"name":"World"},"id":"4"}
SEVERE: 2010-12-16 13:15:50.865:DBUG:bayeux@2001113342:invoke
hello#processHello from 219uwok9hspick1n5and5qda4w6 with {name=World}
SEVERE: 2010-12-16 13:15:50.866:DBUG:bayeux@2001113342:< {"channel":"/
hello","data":{"greeting":"Hello, World"}}
SEVERE: 2010-12-16 13:15:50.866:DBUG:bayeux@2001113342:<< {"channel":"/
service/hello","successful":true,"id":"4"}
SEVERE: 2010-12-16 13:15:50.866:DBUG:bayeux@2001113342:< {"channel":"/
service/hello","successful":true,"id":"4"}
SEVERE: 2010-12-16 13:15:50.712:DBUG:bayeux@2001113342:> {"channel":"/
meta/connect","clientId":"219uwok9hspick1n5and5qda4w6","advice":
{"timeout":0},"connectionType":"long-polling","id":"5"}
219uwok9hspick1n5and5qda4w6
SEVERE: 2010-12-16 13:15:50.967:DBUG:bayeux@2001113342:>> {"channel":"/
meta/connect","clientId":"219uwok9hspick1n5and5qda4w6","advice":
{"timeout":0},"connectionType":"long-polling","id":"5"}
SEVERE: 2010-12-16 13:15:51.065:DBUG:bayeux@2001113342:<< {"channel":"/
meta/connect","advice":{"reconnect":"retry","interval":0,"timeout":
10000},"successful":true,"id":"5"}
SEVERE: 2010-12-16 13:15:51.066:DBUG:bayeux@2001113342:< {"channel":"/
meta/connect","advice":{"reconnect":"retry","interval":0,"timeout":
10000},"successful":true,"id":"5"}
SEVERE: 2010-12-16 13:15:51.216:DBUG:bayeux@2001113342:> {"channel":"/
meta/
connect","clientId":"219uwok9hspick1n5and5qda4w6","connectionType":"long-
polling","id":"6"} 219uwok9hspick1n5and5qda4w6
SEVERE: 2010-12-16 13:15:51.216:DBUG:bayeux@2001113342:>> {"channel":"/
meta/
connect","clientId":"219uwok9hspick1n5and5qda4w6","connectionType":"long-
polling","id":"6"}
SEVERE: 2010-12-16 13:15:51.265:DBUG:bayeux@2001113342:<< {"channel":"/
meta/connect","successful":true,"id":"6"}
SEVERE: 2010-12-16 13:15:55.035:DBUG:bayeux@2001113342:> {"channel":"/
meta/disconnect","clientId":"219uwok9hspick1n5and5qda4w6","id":"7"}
219uwok9hspick1n5and5qda4w6
SEVERE: 2010-12-16 13:15:55.035:DBUG:bayeux@2001113342:>> {"channel":"/
meta/disconnect","clientId":"219uwok9hspick1n5and5qda4w6","id":"7"}
SEVERE: 2010-12-16 13:15:55.035:DBUG:bayeux@2001113342:remove
219uwok9hspick1n5and5qda4w6
SEVERE: 2010-12-16 13:15:55.036:DBUG:bayeux@2001113342:<< {"channel":"/
meta/disconnect","successful":true,"id":"7"}
SEVERE: 2010-12-16 13:15:55.135:DBUG:bayeux@2001113342:< {"channel":"/
meta/disconnect","successful":true,"id":"7"}
SEVERE: 2010-12-16 13:15:55.037:DBUG:bayeux@2001113342:< {"channel":"/
meta/connect","successful":true,"id":"6"}
SEVERE: 2010-12-16 13:15:57.154:DBUG:bayeux@2001113342:removed /hello
SEVERE: 2010-12-16 13:16:15.100:DBUG:bayeux@2001113342:Swept browser
ID c683m16ja9emxcagghrm65gl137n