Grizzly 2.3.11 + Atmosphere 2.1.3: getServletPath() returns null -
hellow fellow developers!
i'm testing atmosphere 2.1.3 using grizzly 2.3.11. i've created managedservice(path="/chat"), error: 'no atmospherehandler maps request /chat status 500 message server error'. if change path managedservice(path="/") works. i've debugged bit , seems org.atmosphere.cpr.atmosphererequest.getservletpath() returns null, default path "/" used , that's cause makes test work using managedservice(path="/").
well, i'll appreciate because need use path kinda managedservice(path="/chat"). in advance!
note: post related atmosphere + grizzly: no atmospherehandler maps request /chat status 500 message server error
pd: main test class:
package com.dweb.atmosphere.grizzly; import java.io.ioexception; import org.atmosphere.container.grizzly2cometsupport; import org.atmosphere.cpr.atmosphereservlet; import org.glassfish.grizzly.comet.cometaddon; import org.glassfish.grizzly.http.server.httpserver; import org.glassfish.grizzly.http.server.networklistener; import org.glassfish.grizzly.http.server.statichttphandler; import org.glassfish.grizzly.servlet.servletregistration; import org.glassfish.grizzly.servlet.webappcontext; import org.glassfish.grizzly.websockets.websocketaddon; public class main { public static void main(string[] args) throws ioexception { final httpserver server = httpserver.createsimpleserver(".", 8181); final webappcontext ctx = new webappcontext("ctx", "/"); // enable web socket support final websocketaddon addon = new websocketaddon(); (networklistener listener : server.getlisteners()) { listener.registeraddon(addon); } // add atmosphere servlet support final atmosphereservlet atmosphereservlet = new atmosphereservlet();. final servletregistration atmosphereservletregistration = ctx.addservlet("atmosphereservlet", atmosphereservlet); atmosphereservletregistration.setinitparameter( "org.atmosphere.websocket.messagecontenttype", "application/json"); atmosphereservletregistration.addmapping("/chat/*"); atmosphereservletregistration.setloadonstartup(1); // deploy ctx.deploy(server); try { server.start(); system.out.println("press enter stop server..."); system.in.read(); } { server.shutdownnow(); } } }
pd2: chatroom test class:
package com.dweb.atmosphere.grizzly; import static org.atmosphere.cpr.applicationconfig.max_inactive; import java.io.ioexception; import org.atmosphere.config.service.disconnect; import org.atmosphere.config.service.get; import org.atmosphere.config.service.managedservice; import org.atmosphere.config.service.ready; import org.atmosphere.cpr.atmosphereresource; import org.atmosphere.cpr.atmosphereresourceevent; import org.slf4j.logger; import org.slf4j.loggerfactory; /** * simple annotated class demonstrate power of atmosphere. class supports transports, support * message length garantee, heart beat, message cache {@link managedservice}. */ @config @managedservice(path = "/chat", atmosphereconfig = max_inactive + "=120000") public class chatroom { private final logger logger = loggerfactory.getlogger(chatroom.class); /** * invoked when connection been established , suspended, e.g ready receiving messages. * * @param r */ @ready public void onready(final atmosphereresource r) { logger.debug("browser {} connected.", r.uuid()); } /** * invoked when client disconnect or when unexpected closing of underlying connection happens. * * @param event */ @disconnect public void ondisconnect(atmosphereresourceevent event) { if (event.iscancelled()) { logger.info("browser {} unexpectedly disconnected", event.getresource().uuid()); } else if (event.isclosedbyclient()) { logger.info("browser {} closed connection", event.getresource().uuid()); } } /** * simple annotated class demonstrate how {@link org.atmosphere.config.managed.encoder} , {@link org.atmosphere.config.managed.decoder * can used. * * @param message instance of {@link message} * @return * @throws ioexception */ @org.atmosphere.config.service.message public string onmessage(string message) throws ioexception { logger.info("just send() {}", message); return message; } }
pd3: server log
apr 23, 2014 2:16:46 pm org.glassfish.grizzly.servlet.webappcontext deploy info: starting application [ctx] ... [main] info org.atmosphere.cpr.atmosphereframework - atmosphere using org.atmosphere.cpr.defaultannotationprocessor processing annotation [main] info org.atmosphere.cpr.defaultannotationprocessor - annotationprocessor class org.atmosphere.cpr.defaultannotationprocessor$bytecodebasedannotationprocessor being used [main] info org.atmosphere.cpr.defaultannotationprocessor - found annotation in com.dweb.atmosphere.grizzly.chatatmospherehandler being scanned: interface org.atmosphere.config.service.atmospherehandlerservice [main] info org.atmosphere.cpr.atmosphereframework - installed atmospherehandler com.dweb.atmosphere.grizzly.chatatmospherehandler mapped context-path /chat2 , broadcaster class org.atmosphere.cpr.defaultbroadcaster [main] info org.atmosphere.cpr.defaultannotationprocessor - found annotation in com.dweb.atmosphere.grizzly.chatroom being scanned: interface org.atmosphere.config.service.managedservice [main] info org.atmosphere.cpr.atmosphereframework - installed atmospherehandler org.atmosphere.config.managed.managedatmospherehandler mapped context-path /chat , broadcaster class org.atmosphere.cpr.defaultbroadcaster [main] info org.atmosphere.cpr.atmosphereframework - installed atmosphereinterceptor [@managedservice interceptor, atmosphere lifecycle, track message size interceptor using |, uuid tracking interceptor] mapped atmospherehandler org.atmosphere.config.managed.managedatmospherehandler [main] info org.atmosphere.cpr.defaultannotationprocessor - found annotation in com.dweb.atmosphere.grizzly.chat being scanned: interface org.atmosphere.config.service.managedservice [main] info org.atmosphere.cpr.atmosphereframework - installed atmospherehandler org.atmosphere.config.managed.managedatmospherehandler mapped context-path /chatzz , broadcaster class org.atmosphere.cpr.defaultbroadcaster [main] info org.atmosphere.cpr.atmosphereframework - installed atmosphereinterceptor [@managedservice interceptor, atmosphere lifecycle, track message size interceptor using |, uuid tracking interceptor] mapped atmospherehandler org.atmosphere.config.managed.managedatmospherehandler [main] info org.atmosphere.cpr.atmosphereframework - auto detecting websockethandler in /web-inf/classes/ [main] info org.atmosphere.cpr.atmosphereframework - installed websocketprotocol org.atmosphere.websocket.protocol.simplehttpprotocol [main] info org.atmosphere.cpr.atmosphereframework - installing default atmosphereinterceptor [main] info org.atmosphere.cpr.atmosphereframework - org.atmosphere.interceptor.corsinterceptor : cors interceptor support [main] info org.atmosphere.cpr.atmosphereframework - org.atmosphere.interceptor.cacheheadersinterceptor : default response's headers interceptor [main] info org.atmosphere.cpr.atmosphereframework - org.atmosphere.interceptor.paddingatmosphereinterceptor : browser padding interceptor support [main] info org.atmosphere.cpr.atmosphereframework - org.atmosphere.interceptor.androidatmosphereinterceptor : android interceptor support [main] info org.atmosphere.cpr.atmosphereframework - org.atmosphere.interceptor.heartbeatinterceptor : heartbeat interceptor support [main] info org.atmosphere.cpr.atmosphereframework - org.atmosphere.interceptor.sseatmosphereinterceptor : sse interceptor support [main] info org.atmosphere.cpr.atmosphereframework - org.atmosphere.interceptor.jsonpatmosphereinterceptor : jsonp interceptor support [main] info org.atmosphere.cpr.atmosphereframework - org.atmosphere.interceptor.javascriptprotocol : atmosphere javascript protocol [main] info org.atmosphere.cpr.atmosphereframework - org.atmosphere.interceptor.websocketmessagesuspendinterceptor : org.atmosphere.interceptor.websocketmessagesuspendinterceptor [main] info org.atmosphere.cpr.atmosphereframework - org.atmosphere.interceptor.ondisconnectinterceptor : browser disconnection detection [main] info org.atmosphere.cpr.atmosphereframework - org.atmosphere.interceptor.idleresourceinterceptor : org.atmosphere.interceptor.idleresourceinterceptor [main] info org.atmosphere.cpr.atmosphereframework - set org.atmosphere.cpr.atmosphereinterceptor.disabledefaults disable them. [main] info org.atmosphere.cpr.atmosphereframework - using endpointmapper class org.atmosphere.util.defaultendpointmapper [main] info org.atmosphere.cpr.atmosphereframework - using broadcastercache: org.atmosphere.cache.uuidbroadcastercache [main] info org.atmosphere.cpr.atmosphereframework - default broadcaster class: org.atmosphere.cpr.defaultbroadcaster [main] info org.atmosphere.cpr.atmosphereframework - broadcaster polling wait time 100 [main] info org.atmosphere.cpr.atmosphereframework - shared executorservice supported: true [main] info org.atmosphere.cpr.atmosphereframework - messaging thread pool size: unlimited [main] info org.atmosphere.cpr.atmosphereframework - async i/o thread pool size: 200 [main] info org.atmosphere.cpr.atmosphereframework - using broadcasterfactory: org.atmosphere.cpr.defaultbroadcasterfactory [main] info org.atmosphere.cpr.atmosphereframework - using websocketprocessor: org.atmosphere.websocket.defaultwebsocketprocessor [main] info org.atmosphere.cpr.atmosphereframework - httpsession supported: false [main] info org.atmosphere.cpr.atmosphereframework - atmosphere using defaultatmosphereobjectfactory dependency injection , object creation [main] info org.atmosphere.cpr.atmosphereframework - atmosphere using async support: org.atmosphere.container.glassfishserv30websocketsupport running under container: grizzly 2.3.11 websocket enabled. [main] info org.atmosphere.cpr.atmosphereframework - atmosphere framework 2.1.3 started. [main] info org.atmosphere.cpr.atmosphereframework - atmosphere framework commercial support, visit http://www.async-io.org/ or send email support@async-io.org apr 23, 2014 2:16:46 pm org.glassfish.grizzly.servlet.webappcontext initservlets info: [ctx] servlet [org.atmosphere.cpr.atmosphereservlet] registered url pattern(s) [[/chat/*]]. apr 23, 2014 2:16:46 pm org.glassfish.grizzly.servlet.webappcontext deploy info: application [ctx] ready service requests. root: [/]. apr 23, 2014 2:16:46 pm org.glassfish.grizzly.http.server.networklistener start info: started listener bound [0.0.0.0:8181] apr 23, 2014 2:16:46 pm org.glassfish.grizzly.http.server.httpserver start info: [httpserver] started. press enter stop server... [thread-1] info org.atmosphere.cpr.atmosphereframework - latest version of atmosphere's javascript client 2.1.5 [grizzly(7) selectorrunner] warn org.atmosphere.websocket.defaultwebsocketprocessor - failed invoking atmosphereframework.docometsupport() org.atmosphere.cpr.atmospheremappingexception: no atmospherehandler maps request /chat @ org.atmosphere.cpr.asynchronousprocessor.map(asynchronousprocessor.java:329) @ org.atmosphere.cpr.asynchronousprocessor.action(asynchronousprocessor.java:133) @ org.atmosphere.cpr.asynchronousprocessor.suspended(asynchronousprocessor.java:95) @ org.atmosphere.container.glassfishserv30websocketsupport.service(glassfishserv30websocketsupport.java:60) @ org.atmosphere.cpr.atmosphereframework.docometsupport(atmosphereframework.java:1805) @ org.atmosphere.websocket.defaultwebsocketprocessor.dispatch(defaultwebsocketprocessor.java:432) @ org.atmosphere.websocket.defaultwebsocketprocessor.open(defaultwebsocketprocessor.java:186) @ org.atmosphere.container.glassfishserv30websocketsupport$grizzly2websocketapplication.onconnect(glassfishserv30websocketsupport.java:144) @ org.glassfish.grizzly.websockets.simplewebsocket.onconnect(simplewebsocket.java:135) @ org.glassfish.grizzly.websockets.websocketengine.upgrade(websocketengine.java:185) @ org.glassfish.grizzly.websockets.websocketengine.upgrade(websocketengine.java:143) @ org.glassfish.grizzly.websockets.websocketfilter.doserverupgrade(websocketfilter.java:104) @ org.glassfish.grizzly.websockets.websocketfilter.handleserverhandshake(websocketfilter.java:87) @ org.glassfish.grizzly.websockets.websocketfilter.handlehandshake(websocketfilter.java:68) @ org.glassfish.grizzly.websockets.basewebsocketfilter.handleread(basewebsocketfilter.java:197) @ org.glassfish.grizzly.filterchain.executorresolver$9.execute(executorresolver.java:119) @ org.glassfish.grizzly.filterchain.defaultfilterchain.executefilter(defaultfilterchain.java:291) @ org.glassfish.grizzly.filterchain.defaultfilterchain.executechainpart(defaultfilterchain.java:209) @ org.glassfish.grizzly.filterchain.defaultfilterchain.execute(defaultfilterchain.java:137) @ org.glassfish.grizzly.filterchain.defaultfilterchain.process(defaultfilterchain.java:115) @ org.glassfish.grizzly.processorexecutor.execute(processorexecutor.java:77) @ org.glassfish.grizzly.nio.transport.tcpniotransport.fireioevent(tcpniotransport.java:550) @ org.glassfish.grizzly.strategies.abstractiostrategy.fireioevent(abstractiostrategy.java:112) @ org.glassfish.grizzly.strategies.samethreadiostrategy.executeioevent(samethreadiostrategy.java:103) @ org.glassfish.grizzly.strategies.abstractiostrategy.executeioevent(abstractiostrategy.java:89) @ org.glassfish.grizzly.nio.selectorrunner.iteratekeyevents(selectorrunner.java:412) @ org.glassfish.grizzly.nio.selectorrunner.iteratekeys(selectorrunner.java:381) @ org.glassfish.grizzly.nio.selectorrunner.doselect(selectorrunner.java:345) @ org.glassfish.grizzly.nio.selectorrunner.run(selectorrunner.java:276) @ org.glassfish.grizzly.threadpool.abstractthreadpool$worker.dowork(abstractthreadpool.java:565) @ org.glassfish.grizzly.threadpool.abstractthreadpool$worker.run(abstractthreadpool.java:545) @ java.lang.thread.run(thread.java:744) [grizzly(7) selectorrunner] warn org.atmosphere.websocket.protocol.simplehttpprotocol - org.atmosphere.cpr.atmospheremappingexception: no atmospherehandler maps request /chat status 500 message server error
hi alexey,
i'm debugging issue, these tests & results:
-. when call 'http://localhost:8181/chat/a/b/c
' internally request built: 'atmosphererequest{ contextpath= servletpath=/chat pathinfo=/a/b/c requesturi=/chat/a/b/c destroyable=true}
' well, http requests seem work fine.
-. when call 'new websocket('ws://localhost:8181/chat/a/b/c')
' internally request built 'atmosphererequest{ contextpath= servletpath=null pathinfo=null requesturi=/chat/a/b/c destroyable=true}
' think problem (servletpath & pathinfo null) happens when use websockets
i'm debbuging method org.glassfish.grizzly.websockets.websocketengine.upgrade(filterchaincontext ctx, httpcontent requestcontent, mapper mapper) , param requestcontent receives value:
httprequestpacket ( method=get url=/chat/a/b/c query=null protocol=http/1.1 content-length=-1 headers=[ upgrade=websocket connection=upgrade host=localhost:8181 origin=http://localhost:8080 pragma=no-cache cache-control=no-cache sec-websocket-key=3prm4vknwqvro8g0/wunbw== sec-websocket-version=13 sec-websocket-extensions=permessage-deflate; client_max_window_bits, x-webkit-deflate-frame user-agent=mozilla/5.0 (x11; linux x86_64) applewebkit/537.36 (khtml, gecko) chrome/34.0.1847.116 safari/537.36] )
but @ end of debugging session method org.atmosphere.util.defaultendpointmapper.computepath(atmosphererequest req) receives param req value: atmosphererequest{ contextpath= servletpath=null pathinfo=null requesturi=/chat/a/b/c destroyable=true}
well hope these tests have value you, anyway if need more tests feel free ask.
have nice day.
miguel
the issue found , fixed in grizzly 2.3.12.
https://java.net/jira/browse/grizzly-1680 code should work is.
Comments
Post a Comment