broadcastMembers error: java.util.concurrent.ConcurrentHashMap$KeySet cannot be cast to java.util.Map

120 views
Skip to first unread message

P

unread,
May 21, 2011, 8:36:42 PM5/21/11
to cometd-users
Following the cometd 2.1.1 chat example, I am getting following error:

java.lang.RuntimeException: java.lang.ClassCastException:
java.util.concurrent.ConcurrentHashMap$KeySet cannot be cast to
java.util.Map
at org.cometd.java.annotation.ServerAnnotationProcessor
$ListenerCallback.onMessage(ServerAnnotationProcessor.java:534)
at org.cometd.server.BayeuxServerImpl.doPublish(BayeuxServerImpl.java:
748)
at org.cometd.server.ServerChannelImpl.publish(ServerChannelImpl.java:
217)
at org.cometd.server.BayeuxServerImpl.handle(BayeuxServerImpl.java:
604)
...

The error printout is long and only file that I have adjusted code is
ChatService.java file, code:
channel.publish(members);

where Log.info(members) prints out: [Guest001]


ChatService.java file:
...
broadcastMembers(room,members.keySet());
...
private void broadcastMembers(String room, Set<String> members)
{
// Broadcast the new members list
ClientSessionChannel channel =
_session.getLocalSession().getChannel("/members/"+room);
Log.info("members keyset:" + members);
channel.publish(members);
}


It is quite strange as I know it should work...any ideas?

P.

Simone Bordet

unread,
May 25, 2011, 10:39:17 AM5/25/11
to cometd...@googlegroups.com
Hi,

My guess is that you're doing a wrong cast in your @Listener method. I
just tried to pass a HashSet to publish() and works for me.
The stack trace (not truncated) should give you more information on
where is the problem, search for "caused by".

Simon
--
http://bordet.blogspot.com
---
Finally, no matter how good the architecture and design are,
to deliver bug-free software with optimal performance and reliability,
the implementation technique must be flawless.   Victoria Livschitz

Reply all
Reply to author
Forward
0 new messages