Crossdomain with jsonp

31 views
Skip to first unread message

JMan

unread,
Mar 9, 2008, 6:15:38 AM3/9/08
to cometd-users
Hello,
im trying to get cometd working in an crossdomain setup. I moved the
chat example to my iis on port 80 and let it use the jetty-cometd on
8080. On the client side it seems fine. When i try to join it send
this get request:
http://localhost:8080/cometd?message=[{"version": "1.0",
"minimumVersion": "0.9", "channel": "/meta/handshake", "id": "0",
"ext": {"timesync": {"ts": 1205057452031, "i":
6922}}}]&jsonp=dojo.io.script.jsonp_dojoIoScript1._jsonpCallback"
But on the service side a NullPointerException is thrown:
java.lang.NullPointerException
at org.mortbay.cometd.AbstractBayeux
$HandshakeHandler.handle(AbstractBayeux.java:988)
at org.mortbay.cometd.AbstractBayeux.handle(AbstractBayeux.java:308)
at
org.mortbay.cometd.continuation.ContinuationCometdServlet.doPost(ContinuationCometdServlet.java:
98)
at
org.mortbay.cometd.continuation.ContinuationCometdServlet.doGet(ContinuationCometdServlet.java:
45)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at
org.mortbay.cometd.AbstractCometdServlet.service(AbstractCometdServlet.java:
220)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
487)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:
362)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:
181)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:
726)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:
405)
at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:
206)
at
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:
114)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
505)
at org.mortbay.jetty.HttpConnection
$RequestHandler.headerComplete(HttpConnection.java:828)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:
395)
at org.mortbay.thread.BoundedThreadPool
$PoolThread.run(BoundedThreadPool.java:450)

Is this a known issue, or what can i do about it?

thanks, JMan

Greg Wilkins

unread,
Mar 12, 2008, 7:04:06 AM3/12/08
to cometd...@googlegroups.com

JMan,

what version of jetty are you using? We had some crossdomain regressions in some
recent releases (OK we stuffed up!).

But it is working fine for me in the jetty 6.1.8 release.

cheers

Johannes Elsinghorst

unread,
Mar 12, 2008, 1:13:46 PM3/12/08
to cometd...@googlegroups.com
Greg,
i tried 6.1.8 and 8.1.7 as well as the current svn-trunk. Does the
request in your setup look the same as mine?

thanks, JMan

Greg Wilkins

unread,
Mar 16, 2008, 6:24:46 PM3/16/08
to cometd...@googlegroups.com
Johannes Elsinghorst wrote:
> Greg,
> i tried 6.1.8 and 8.1.7 as well as the current svn-trunk. Does the
> request in your setup look the same as mine?

Yes - very similar.

To test this, all I have done was edit the chat.js file to use
an absolute http:// with my IP address. I then load the example from
local host and the jsonp conversation works via the IP address.

Can you try that with the demo and confirm if you get the same NPE?

cheers

Stefaan

unread,
Mar 20, 2008, 11:17:52 AM3/20/08
to cometd-users
Hello,
I can confirm that.
The NPE occurs int he following situation:
in the chat demo,do dojox.cometd.init("http://127.0.0.1:8080/
cometd");
Then open your browser not on 127.0.0.1 but on: http://localhost:8080/examples/chat.
The NPE occurs at
boolean commented=_JSONCommented && ext!=null &&
((Boolean)ext.get("json-comment-filtered")).booleanValue();
because ext has no "json-comment-filtered" key
This is because of the following code in dojox\cometd\_base.js:
if(!this._isXD){
if(props.ext){
if(props.ext["json-comment-filtered"]!==true && props.ext["json-
comment-filtered"]!==false){
props.ext["json-comment-filtered"] = true;
}
}else{
props.ext = { "json-comment-filtered": true };
}
props.supportedConnectionTypes =
dojo.map(this.connectionTypes.pairs, "return item[0]");
}
this._isXD is true so the json-comment-filtered does not get set.
I added an leg locally which sets it to false and ofcourse the NPE
disappeared but....
it still did not getting cross domain cometd working for me. Any
further hints?
Thanks,
Stefaan
dojo 1.1B2, jetty 6.1.7

Greg Wilkins

unread,
Mar 21, 2008, 2:45:23 AM3/21/08
to cometd...@googlegroups.com
6.1.7 was definitely broken....

Stefaan

unread,
Mar 21, 2008, 9:59:39 AM3/21/08
to cometd-users
Got cross domain chat sample working for jetty 6.1.8
But only after a fix in /dojo/dojox/cometd/_base.js (dojo 1.1B2)
The fix is to append an else statement to the following if:
if(!this._isXD){
if(props.ext){
if(props.ext["json-comment-filtered"]!==true && props.ext["json-
comment-filtered"]!==false){
props.ext["json-comment-filtered"] = true;
}
}else{
props.ext = { "json-comment-filtered": true };
}
props.supportedConnectionTypes =
dojo.map(this.connectionTypes.pairs, "return item[0]");
}
The else to append is:
else {
props.ext = { "json-comment-filtered": false };
}
An alternative fix would be for you to check for null for
ext.get("json-comment-filtered") at:
988: boolean commented=_JSONCommented && ext!=null &&
((Boolean)ext.get("json-comment-filtered")).booleanValue();
in org.mortbay.cometd.AbstractBayeux.
Cheers.
Stefaan


On Mar 21, 7:45 am, Greg Wilkins <gr...@mortbay.com> wrote:
> 6.1.7 was definitely broken....

akhval

unread,
Mar 18, 2008, 4:08:16 PM3/18/08
to cometd-users
Have anybody crossdomain cometd ran on Jetty with Dojo?
Looks like it's completely doesn't work.
The simple example : take chat example and replace the relative cometd
path to IP of your PC.

Alex
Reply all
Reply to author
Forward
0 new messages